我试图提出以下问题:
SELECT * FROM Example WHERE id IN (1, 4 ,53 ,53, 95, 12, 54, 54)
我希望从示例中得到8个值,但我只得到6个值,因为ID53和ID54是重复的。有没有办法为每个id获取一个值?
dauxcl2d1#
如前所述,in子句中的重复值将被忽略。我已经用javascript解决了我的问题。
bybem2ql2#
你需要使用 left join . 比如:
left join
select e.* from (select 1 as id union all select 4 union all select 53 union all select 53 union all select 95 union all select 12 union all select 54 union all select 54 ) i left join example e on i.id = e.id;
2条答案
按热度按时间dauxcl2d1#
如前所述,in子句中的重复值将被忽略。我已经用javascript解决了我的问题。
bybem2ql2#
你需要使用
left join
. 比如: