Mysql – WHERE clause before INNER JOIN

joinmysqloptimizationwhere

If I have

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

Does the WHERE clause run after the two tables are JOINED?

How do I make it so it runs prior to the JOIN?

Best Solution

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.