-1

我想做这样的事情:

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 以获得正确的结果?

4

4 回答 4

1
 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!
于 2013-08-01T05:53:26.723 回答
0

您需要使用该列。

select * 
from dictionary t1, dictionary t2 
where t1.category<>t2.category and t1.tag<>t2.tag and t1.word like '% ' + t2.word + ' %';
于 2013-08-01T05:52:41.667 回答
0
select * 
from dictionary t1, dictionary t2 
where t1.category<>t2.category and t1.tag<>t2.tag and t1.word like '%'+ t2.word +'%';
于 2013-08-01T05:52:51.917 回答
0

这就是你要找的:

select * 
from dictionary t1, dictionary t2 
where t1.category<>t2.category and t1.tag<>t2.tag and t1.word like '% ' + t2.word + ' %';
于 2013-08-01T05:56:22.590 回答