0

I have wrong result in my query because I don't get any results but the definitely are there.

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%')

When I only use first subquery I get results, but with the second subquery in it I don't

1 Answer 1

2

Use OR instead of 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%')

And join is useless if it is exact same query that u use.

Elegant way is

select nr from table1 
 inner join table2 on table2.nr = table1.nr
 where CONTAINS(table2.column, '"*value*" OR "*other value*"')
Sign up to request clarification or add additional context in comments.

4 Comments

i cant use or becase i need the nr to be in the first subquery and the second 1 and like that i get results from nr in one of the 2 subquery's
can you post a sample data and expected output?
Tanx for the query i just need to add full text indexed on table2 will let you know result
Can you maybe help me with enableing full text search on a table in sql server 2008 becase its greyd out and i can not get it enabled

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.