Select query with combination of two columns
985847Jan 25 2013 — edited Jan 27 2013I need looking to write a nested select statement that would achieve the following.
Support i have a table as follows
TestTable
Name : Age : Country
Test1 : 10 : USA
Test2 : 11 : USA
Test3 : 12 : USA
Test4 : 11 : Canada
Test5 : 12 : Canada
Now i want to select from the above table the following information.
Get all the names of people who dont belong to this combinations (10:USA,11:Canada,12:Canada). The list can be huge.
The result should be
Test1:10:USA
Test1:12:USA
If it were one combination i can write
select * from TestTable
where age <> 10 and country <>Canada
Also i can also do
select * from TestTable
where age NOT IN (10,11) and country NOT IN (USA,COUNTRY)
But i don't this it would give me correct result.