求一sql语句

ad2008 2007-11-30 05:35:11
我写的这个sql查不出来结果,目的是要能出来这种sql结果就对了,fgroups里保存的是用逗号分隔的组ID
select a.* from fz_product a where a.uid=12 and 1 in (1,5)

这是我写的sql
select a.* from fz_product a where a.uid=12 and 1 in (select b.fgroups from fz_product b where a.proid=b.proid)
...全文
130 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhunanhui 2007-11-30
  • 打赏
  • 举报
回复
你的b.fgroups字段不是字符形会报错,另外查询的结果还是空啊.
ad2008 2007-11-30
  • 打赏
  • 举报
回复
出来了出来了,给高手检验一下,看在下的结果对不对

select a.* from fz_product a where a.uid=12 and concat(',',(select b.fgroups from fz_product b where a.proid=b.proid),',') like concat('%,',rtrim(1),',%')
areswang 2007-11-30
  • 打赏
  • 举报
回复
高手好像来一次就走了。帮顶!
ad2008 2007-11-30
  • 打赏
  • 举报
回复
子陌红尘你好,高手啊,你的写法我还未见过,不知道如何将它换成mysql呢,谢谢
zhunanhui 2007-11-30
  • 打赏
  • 举报
回复
select a.* from fz_product a where a.uid=12 and 1 in
(select b.fgroups from fz_product b )
子陌红尘 2007-11-30
  • 打赏
  • 举报
回复

select
a.*
from
fz_product a
where
a.uid=12
and
','+(select b.fgroups from fz_product b where a.proid=b.proid)+',' like '%,'+rtrim(1)+',%'

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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