这是我的查询
select id from ((select id from users where id = 2
)
union all
(select id from users where id = 1
)
union all
(select id from users where id = 1
)
union all
(select id from users where id = 4
)
union all
(select id from users where id = 3
)
)results group by id
我得到的输出是
id
----
1
2
3
4
我预期的输出是
id
----
2
1
4
3
有什么解决方案吗?
我需要id的结果组,而不是有序列表
答案 0 :(得分:0)
好像你需要这样的东西不是所有的联合
SELECT `id` FROM `users` WHERE id IN(1,2,3,4);