查询id是否包含在id字符串中

细嗅蔷薇 2015-09-11 04:24:59

create table ic(
id int paimary key identity(1,1),
name varcahr(50)
)
create table iclist
(
id int primary key identity(1,1),
icname varchar(200),
icid varchar(50),
ictime date
)
insert into iclist values('专题纪委会20141230第十次会议','10,19,30',getdate());
insert into iclist values('院技委会2015年(03)号会议通知','6,9,11',getdate());
insert into iclist values('院2015(10)号会议通知','23,12,15',getdate());

--只是想查询ic表中id在 iclist表中icid字段中的数据
--类似于
select * from ic where id in(select icid from iclist)
...全文
223 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_17482963 2015-09-11
  • 打赏
  • 举报
回复
怎麼看都像是簡單的查詢
qq_17482963 2015-09-11
  • 打赏
  • 举报
回复
select b.* from ic a inner join iclist b on a.id=b.icid
等不到来世 2015-09-11
  • 打赏
  • 举报
回复
select * from ic t
where exists(select 1 from iclist
where CHARINDEX(','+RTRIM(t.id)+',',','+icid+',')>0)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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