SQL JOIN where to place the WHERE condition?

前端 未结 3 735
独厮守ぢ
独厮守ぢ 2020-12-08 04:25

I have two following examples.

1. Example (WHERE)

SELECT 1
  FROM table1 t1
  JOIN table2 t2 ON t1.id = t2.id
 WHERE t2.field = true         


        
3条回答
  •  攒了一身酷
    2020-12-08 04:51

    JOIN conditions should normally be independent from filter conditions. You define rules of your join (the how) with ON. You filter what you want with WHERE. Performance wise, there's no general rule across all engines and designs, so your mileage will vary greatly.

提交回复
热议问题