Hi,
In one table i have a data like this
Table1
code1 code2 code3
12 1 1
12 1 2
12 2 1
And in an another table i have a data like this
Table2
code1 code2 code3
12 1 1
Code1 is common in both table
But i need only those data which are not in Table2.
ie.
code1 code2 code3
12 1 2
12 2 1
How can write the query to get those data.
Thanks
Data Filtering
Moderator: General Moderators
Code: Select all
SELECT `code1`,`code2`,`code3` FROM `Table1`
WHERE `code1` NOT IN (SELECT `code1` FROM `Table2`)- Gente
- Forum Contributor
- Posts: 252
- Joined: Wed Jun 13, 2007 9:43 am
- Location: Ukraine, Kharkov
- Contact:
Seems this code in this situation is equal toanjanesh wrote:Code: Select all
SELECT `code1`,`code2`,`code3` FROM `Table1` WHERE `code1` NOT IN (SELECT `code1` FROM `Table2`)
Code: Select all
SELECT `code1`,`code2`,`code3` FROM `Table1`
WHERE `code1` NOT IN (12)Can you try it
Code: Select all
SELECT `Table1`.`code1`, `Table1`.`code2`,`Table1`.`code3`
FROM `Table1`
INNER JOIN `Table2`
ON (`Table1`.`code1` != `Table2`.`code1` OR `Table1`.`code2` != `Table2`.`code2` OR `Table1`.`code3` != `Table2`.`code3`)