Reputation: 33
i have the below query:
Select * from table1,table2 where table1.id!=table2.itid
when i run this query it gives multiple rows.
Table1:
id itemname
1 xyz
2 abc
3 dskd
4 asda
Table 2:
itemdetail table1_id
jkj 2
hud 3
so i want the below output
:
id itemname
1 xyz
4 asda
how can i do this?
Upvotes: 2
Views: 85
Reputation: 2153
Try this
SELECT * FROM table1 WHERE table1.id NOT IN(SELECT table2.itid FROM table2)
Upvotes: 1
Reputation: 436
Try this, but I'm not sure of the syntax right now:
Select * from table1,table2 where table1.id NOT IN table2.itid
Upvotes: 1