Hi,
you could try:
SELECT tbl1.id
FROM tbl1
LEFT JOIN tbl2 ON tbl2.another_id = tbl1.id
WHERE tbl2.id IS NULL
/Johan
Manish wrote:
This should be simple but I am stuck here. I need to select rows from table
1, which do not have matching ID in table 2.
Say each table has 100 rows each, and 90 rows from table 1 have matching 90
rows in table 2. SO I want to find remaining 10 rows. Simple query such as
select tbl1.id from tbl1, tbl2 where tbl1..id = tbl2.another_id;
returns me the matching 90 rows, but my job is now to find out remaining 10
rows, how do I do it. I have done this before but can't recall it now,
simply replacing "=" with "<>" naturally returns Cartesian product.
Any help will be highly appreciated.
TIA,
- Manish
--
Johan Höök, Pythagoras Engineering Group
- MailTo:[EMAIL PROTECTED]
- http://www.pythagoras.se
Pythagoras AB, Stormbyv. 2-4, SE-163 55 SPÅNGA, Sweden
Phone: +46 8 760 00 10 Fax: +46 8 761 22 77
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]