mysql in 有关问题

原创
2016-06-13 10:53:34 652浏览

mysql in 问题
数据库里有如下数据:

person表
id name
1 zhangsan
2 lisi

SQL code
select * from person where id in (1,2,2,2,2);


以上查询只能得到 1,2的数据,如下
id name
1 zhangsan
2 lisi
我想得到重复的2的数据,如下,该怎么做啊谢谢
id name
1 zhangsan
2 lisi
2 lisi
2 lisi
2 lisi

------解决方案--------------------
select * from person where id =1
union all
select * from person where id =2
union all
select * from person where id =2
union all
select * from person where id =2
union all
select * from person where id =2
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。