我们需要这样做:
select *
from table1 as t
where t.num = 111
orderby t.createon
如果没有返回的记录 - 做不同的选择:
select *
from table1 as t
orderby t.createon
有什么方法可以加入这些选择吗? 谢谢!
答案 0 :(得分:1)
SELECT
*
FROM
table1 as t
WHERE
EXISTS((SELECT * FROM table1 WHERE num = 111) AND t.num = 111)
OR NOT EXISTS (SELECT * FROM table1 where num = 111)
ORDER BY
t.createon