fetch the records in one table which is not exist in another table using mysql
I am trying to fetch the records in one table which is not exist in another table using mysql. It is having 1 to many relationship.
I am working with approx. 50,000 numbers of data.I have tried it using two queries but when I fire queries, my database hangs and website crashes. :confused: Please help. Below is my query.
SELECT DISTINCT a.id FROM abc as a WHERE a.id NOT IN (SELECT b.a_id FROM xyz as b)
SELECT DISTINCT a.id from abc as a LEFT OUTER JOIN xyz as b on (a.id=b.a_id) where b.a_id is null