当前位置: 代码迷 >> Sql Server >> SQL Server能不能实现两表用like联系关系
  详细解决方案

SQL Server能不能实现两表用like联系关系

热度:44   发布时间:2016-04-27 11:34:47.0
SQL Server能不能实现两表用like关联
表1中有a字段 表2中有b字段
如果获得下面的集合
select 1.a from 1,2 where 1.a like 2.b

------解决方案--------------------
可以 
不过你这个跟等号没区别

这样
SQL code
select 1.a from 1,2 where 1.a like '%'+2.b+'%'--orselect 1.a from 1,2 where 1.a like '%'+2.b
------解决方案--------------------
用like 或是用charindex 都可以
------解决方案--------------------
用charindex 吧! 用 LIKE 的话,写的不好容易出错
------解决方案--------------------
对的 用charindex
  相关解决方案