select 'none', '0'
union
select * from category where id='2'
我可以检索上述sqlite 查询的输出,因为'none' 应该始终是第一项吗?即我想阻止两个结果集的组合排序。请帮助...
select 'none', '0'
union
select * from category where id='2'
我可以检索上述sqlite 查询的输出,因为'none' 应该始终是第一项吗?即我想阻止两个结果集的组合排序。请帮助...
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
我会避免SELECT *
在联合查询中使用
SELECT 'none', '0', 0 AS sort
UNION
SELECT col1, col2, 1 AS sort
FROM category
WHERE id = '2'
ORDER BY sort ASC