select 'none', '0'
union
select * from category where id='2'
我可以检索上面sqlite查询的输出,因为'none'应该始终是第一项吗?,即我想阻止两种结果集的组合排序。请帮忙......
答案 0 :(得分:6)
select * from
(
select 'none' as col1, '0' as col2 union select * from category where id='2'
) t
order by case when col1='none' then 0 else 1 end
答案 1 :(得分:2)
我会避免在联合查询中使用SELECT *
SELECT 'none', '0', 0 AS sort
UNION
SELECT col1, col2, 1 AS sort
FROM category
WHERE id = '2'
ORDER BY sort ASC