2

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?

2
  • Could you expand your question a little? Like showing a part of your tables and what you'd like to get? It is logical that this query returns many rows Commented Jul 30, 2015 at 17:48
  • pleae check my updated question. Commented Jul 30, 2015 at 17:53

2 Answers 2

1

Try this

   SELECT * FROM table1 WHERE table1.id NOT IN(SELECT table2.itid FROM table2)
Sign up to request clarification or add additional context in comments.

Comments

1

Try this, but I'm not sure of the syntax right now:

Select * from table1,table2 where table1.id NOT IN table2.itid

Comments

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.