WHERE clause before INNER JOIN

In my experience in a left join you cannot exclude records in the 'left' (t1) table in the ON-statement since - by definition - all t1 records will be included. The where statement does work as it will be applied to the result of the join afterwards.

I do not exactly know what you want to achieve but most probably an inner join suits your needs as well and then you can add the t1.user='bob' condition to the ON-statement.

But if Mosty Mostacho is correct, the location (WHERE vs ON) of the condition is not relevant for speed of execution.


You should just add t1.user='bob' condition to ON clause before other condition and it will be evaluated first:

SELECT * FROM Table1 t1 
LEFT JOIN Table2 t2
ON t1.user='bob' AND t1.id = t2.id;

Change the WHERE to another JOIN condition

LEFT JOIN Table2 t2 on t1.id = t2.id AND t1.user='bob'


The where clause will be executed before the join so that it doesn't join unnecessary records. So your code is fine the way it is.