您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql in 有关问题

2024/2/24 22:13:32发布15次查看
mysql in 问题
数据库里有如下数据:
person表
id name 
1 zhangsan
2 lisi
sql codeselect * 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
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product