select * form name where inst in('11','22')能得到结果,为什么group_concat生成的不行

prettywolf 2014-11-18 11:50:41
select * form name where inst in('11','22')能得到inst 为11或22的记录
select group_concat('\'',content,'\'') from other where FIND_IN_SET(id,getChildList(1))
的结果是'11','22'
但是select * form name where inst in(select group_concat('\'',content,'\'') from other where FIND_IN_SET(id,getChildList(1)))
却返回不了记录。
请问是什么回事呢?
...全文
278 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
prettywolf 2014-11-24
  • 打赏
  • 举报
回复
很感谢各位的回复,考滤到效率各方面的问题,我修改了数据库,把那字符串改成int 型id,这样方便点,而且效率应该也会高点。
WWWWA 2014-11-19
  • 打赏
  • 举报
回复
where inst in(select group_concat('\'',content,'\'') from other where FIND_IN_SET(id,getChildList(1)))-> where FIND_IN_SET(inst,(select group_concat('\'',content,'\'') from other where FIND_IN_SET(id,getChildList(1))))
rucypli 2014-11-19
  • 打赏
  • 举报
回复
这样写 select * form name where inst in(select content from other where FIND_IN_SET(id,getChildList(1)))
benluobo 2014-11-19
  • 打赏
  • 举报
回复
select * form name where inst in('11','22')能得到inst 为11或22的记录 这里面的11和22是两个元素,用in操作的时候11和22都可以匹配 select group_concat('\'',content,'\'') from other where FIND_IN_SET(id,getChildList(1)) 这个得到的结果'11','22'是一个整体,也就是元素是单个就是('11','22') ,括号为了看的清除 此时用in就不是匹配11和22两个了
chengchow2001 2014-11-19
  • 打赏
  • 举报
回复
你用了group_concat结果是11,22不假,但是被识别成'11,22'(字符串),而不是11,22(数字集) 所以你查询不出结果

56,681

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧