SQL使用包含或喜欢'%%'和IN一起使用

时间:2015-11-26 06:58:07

标签: sql sql-like contains where-in

有没有办法编写我们可以执行的SQL查询包含检查列到子查询/函数

即。以这种方式

select * from where COLUMN contains IN (select * from func)

select * from where '%'+ COLUMN + '%' IN (select * from func)  

2 个答案:

答案 0 :(得分:2)

试试这个,

Select * From  table_name A
Where Exists (Select *  From table_name B 
                 Where B.Column Like '%' + A.Column +'%')

答案 1 :(得分:0)

审核了我的答案,因为我似乎误解了这个问题

    Select a.*
    from foo a,
    (select * from func) b
    where a.id = b.id or a.id like '%'+convert(varchar,b.id)+'%'

这将选择结果集列id相等或类似%b.id%

的记录