HI all,
if i do a select * from table
the output of ID
column will be 1,2,3,4,5,6,7,8,9... etc.
is there anyway i can do a select * from table where id not in (3,6,9)
then a select * from table where id in (3,6,9)
in one query so the output will be like 1,2,4,5,7,8,10.... 3,6,9???
Thank you.
Edit:
select * from table order by ts desc
then select * from table where id in (3,6,9)
?
SELECT *
FROM table
ORDER BY CASE WHEN id in (3,6,9) THEN id ELSE 1 END
RE: Your Edit:
SELECT *
FROM table
ORDER BY CASE WHEN id in (3,6,9) THEN 1 ELSE 0 END ASC, ts DESC
What about
select * from table where id not in (3,6,9)
UNION ALL
select * from table where id in (3,6,9)
You could do
select * from table where id not in (3,6,9)
union
select * from table where id in (3,6,9)
You could use a UNION
query:
SELECT ...
UNION
SELECT ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.