日期:2014-05-18  浏览次数:20317 次

有没有类似于 like in 的查询方法
举例

我要在表a name 字段中查询

表a

id name country
1 汽车 中国、印度
2 纺织品 美国
3 石油 日本
4 出版物 墨西哥、中国
5 农作物 韩国、日本
6 核废料 朝鲜、加拿大

表b
country
中国
美国
日本

我想做类似 select a.* from a where a.country like in( select country from b )

得到 

  汽车 中国、印度
2 纺织品 美国
3 石油 日本
4 出版物 墨西哥、中国
5 农作物 韩国、日本

------解决方案--------------------
SQL code
select a.* from a,b 
 where ','+a.country+',' like '%,'+b.country+',%'

------解决方案--------------------
select a.* from a , b 
where '、' + a.country + '、' like '%、' + b.country + '、%'

select a.* from a , b 
where charindex('、' + b.country + '、' , '、' + a.country + '、') > 0
------解决方案--------------------
select distinct a.* from a join b where a.country like '%' + b.country + '%'
------解决方案--------------------
SQL code
select  a.* from a join b where a.country like '%' + b.country + '%'