我想做这样的事情:
SELECT *
FROM
dictionary t1,
dictionary t2
WHERE t1.category <> t2.category
AND t1.tag <> t2.tag
AND t1.word LIKE '% t2.word %';
如何编写'% t2.word %'
部分 SQL 以获得正确的结果?
select *
from dictionary t1,
dictionary t2 -- <- Is there an intentional Cartesian Join?
where t1.category <> t2.category and
t1.tag <> t2.tag and
t1.word like '% ' || t2.word || ' %'; -- <- check spaces!
您需要使用该列。
select *
from dictionary t1, dictionary t2
where t1.category<>t2.category and t1.tag<>t2.tag and t1.word like '% ' + t2.word + ' %';
select *
from dictionary t1, dictionary t2
where t1.category<>t2.category and t1.tag<>t2.tag and t1.word like '%'+ t2.word +'%';
这就是你要找的:
select *
from dictionary t1, dictionary t2
where t1.category<>t2.category and t1.tag<>t2.tag and t1.word like '% ' + t2.word + ' %';