sql中,查找A表中某字段在B表中某字段中包含的记录,该怎么写

2024-12-05 07:42:16
推荐回答(4个)
回答1:

要么你数据库设计有问题。

这没法一起查,查出来的都是2表堆在一起的,实在要查的话这样
select a.*,b.* from a,b where a.it=b.code and b.code='S'

回答2:

Sql Server 如下:
一:
select * from a where exists
(select 1 from b where code='S' and b.value+',' like '%'+a.it+',%' )

二:
select * from a where
(select count(1) from b where code='S' and b.value+',' like '%'+a.it+',%' ) >0

回答3:

用like进行模糊查询
select * from A where it like (select code from B where code like 'S%')

回答4:

select * from a,b where a.it=b.code and b.code='S'