Which performs first WHERE clause or JOIN clause

前端 未结 5 1497
萌比男神i
萌比男神i 2021-02-01 18:47

Which clause performs first in a SELECT statement?

I have a doubt in select query on this basis.

consider the below example

         


        
5条回答
  •  滥情空心
    2021-02-01 18:58

    Logical order of query processing phases is:

    1. FROM - Including JOINs
    2. WHERE
    3. GROUP BY
    4. HAVING
    5. SELECT
    6. ORDER BY

    You can have as many as conditions even on your JOINs or WHERE clauses. Like:

    Select * from #temp A 
    INNER JOIN #temp B ON A.id = B.id AND .... AND ... 
    INNER JOIN #temp C ON B.id = C.id AND .... AND ...
    Where A.Name = 'Acb'
    AND B.Name = C.Name
    AND ....
    

提交回复
热议问题