我的查询结果错误,因为我没有得到任何结果,但绝对存在。
QUERY
select nr
from table1
inner join table2 on table2.nr = table1.nr
where table1.nr in (select nr
from table2
where columnn like '%value%')
and nr in (select nr from table2 where columnn like '%other value%')
当我只使用第一个子查询时,我得到了结果,但是其中的第二个子查询我没有
答案 0 :(得分:2)
使用OR而不是AND
select nr from table1
inner join table2 on table2.nr = table1.nr
where table1.nr in (select nr from table2 where columnn like '%value%') or nr in
(select nr from table2 where columnn like '%other value%')
如果与你使用的查询完全相同,则加入是无用的。
优雅的方式是
select nr from table1
inner join table2 on table2.nr = table1.nr
where CONTAINS(table2.column, '"*value*" OR "*other value*"')