Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL join ON not equal in Mysql

Tags:

mysql

I have two tables. Both contains question id field. I want to get all records from first table that are not present in second one. I don't want to use "NOT IN" constrain as second table having more than 400000 records.

like image 416
Nilesh Avatar asked Feb 18 '11 11:02

Nilesh


1 Answers

Try something like

SELECt  t1.*
FROM    Table1 t1 LEFT JOIN
        Table2 t2   ON  t1.questionID = t2.questionID
WHERE   t2.questionID IS NULL
like image 152
Adriaan Stander Avatar answered Sep 30 '22 05:09

Adriaan Stander