Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
07-12-2011, 08:19 PM #1
- Join Date
- Jul 2010
- Thanked 5 Times in 5 Posts
How to get data using single select query
I'm created two table first one is test1 and second one is test2.
In first table one field is id and in second table one field is id.
in first table two data/value insert 1 and 2 and second table four data/value insert 1, 2, 3 and 4
I want to access only 3 and 4 data with use join key
Is this possible to get data using single select query.
07-12-2011, 10:40 PM #2
But you might find it easier to think of if you do it this way:Code:SELECT table2.* FROM table2 LEFT JOIN table1 ON table2.id = table1.id WHERE table1.id IS NULL
The two queries really do the same thing.Code:SELECT * FROM table2 WHERE id NOT IN ( SELECT id FROM table1 )