SELECT 开发者_运维技巧h11, HA11
FROM florin.h11
WHERE (3>d1 AND 3<d2) OR (3>d1 AND 3=d2 AND id=MAX(id))
UNION (3=d1 AND 3<d2 AND id=MIN(id));
Here a screenshot of my table stucture:
I think what you would like to do is something like this:
SELECT h11, HA11
FROM florin.h11
WHERE (3>d1 AND 3<d2)
OR (3>d1 AND 3=d2 AND id = (SELECT MAX(t2.id)
FROM florin.h11 AS t2))
OR (3=d1 AND 3<d2 AND id = (SELECT MIN(t3.id)
FROM florin.h11 AS t3));
First wrong thing is
- Please mention if, florin is database and h11 is table.
If florin is table then write only "select h11,HA11 from florin", don't write column name.
Second wrong thing is
- Union operator is used to join results of two query. For more info surf www.w3school.com
So, fire query like
select h11, HA11
from florin
where (3 > d1 and 3 < d2) or (3 > d1 and 3 = d2 and id = MAX(id))
union
select h11, HA11
from florin
where (3 = d1 and 3 < d2 and id = MIN(id))
Here may this query doesn't return desired result but this was my imagine that you want such type of query.
精彩评论