首先看一下这个场景:
我的table1包含C1列,其中有2条记录,其值为Text1和Text2。
SELECT * FROM TabelX
INNER JOIN table1 ON TableX.Name LIKE '%'+table1.C1+'%'
此代码表示:
SELECT * FROM TabelX
WHERE TableX.Name LIKE '%Text1%' OR TableX.Name LIKE '%Text2%'
现在我怎么能改变JOIN LIKE这意味着AND而不是OR?类似的东西:
SELECT * FROM TabelX
WHERE TableX.Name LIKE '%Text1%' AND TableX.Name LIKE '%Text2%'
答案 0 :(得分:0)
我觉得这样的事情对你有用:
BEGIN
declare @mycounter integer
select @mycounter = count (*) from table1
SELECT * FROM TabelX
where @mycounter = (select * from table1 where TableX.Name LIKE '%'+table1.C1+'%')
END