oracel sql查询语句用in查询的时候,如何让重复的数据也显示出来?
如题,比如我们写一条select*fromuerwhereidin('1','2','3','4,'2','4'');一般情况下他查询出来的数据只会显示4条,如果想让他6...
如题,比如我们写一条 select * from uer where id in ('1','2','3','4,'2','4''); 一般情况下他查询出来的数据只会显示4条,如果想让他6条都显示出来,该怎么做呢?关联其他表?
展开
1个回答
展开全部
SELECT * FROM
(
SELECT '1' AS ID FROM DUAL UNION ALL
SELECT '2' AS ID FROM DUAL UNION ALL
SELECT '3' AS ID FROM DUAL UNION ALL
SELECT '4' AS ID FROM DUAL UNION ALL
SELECT '2' AS ID FROM DUAL UNION ALL
SELECT '4' AS ID FROM DUAL
) T1 LEFT JOIN UER T2 ON T1.ID=T2.ID
如果都要显示,你就只能造一张ID的临时表作为左表,去left join uer表
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询