0

I have a query regarding IN clause that I am trying to use and getting weird result .

I have two tables as below :

Table-Topics

Table- Cat

Query 1-

select topic_cat from Topics ; 

giving result as expected 1,2,3,4,5;

Query 2-

select cat_name 
from Cat 
where cat_id in(1,2,3,4,5); 

giving result as expected cat1 cat2 cat3 cat4 cat5

Query 3-

select cat_name 
from Cat,Topics 
where cat_id in(topic_cat)

I am getting cat1 as the result of above query where as I expect the result to be cat1 cat2 cat3 cat4 cat5

What is wrong in my understanding for IN Clause ?

Barmar
  • 741,623
  • 53
  • 500
  • 612
milan kumar
  • 226
  • 2
  • 16

0 Answers0