doubo4824 2013-12-06 14:03
浏览 113
已采纳

Sql执行顺序[关闭]

I am confusing with simple query:

SELECT * FROM table_name WHERE name = 'stack';

My question is this which part first execute:

SELECT * FROM table_name

OR

WHERE name = 'stack'

First select all record from table then filter with WHERE condition or first filter records then SELECT?

For more details about question please see this link:

WHERE condition issue in SQL

Thanks

  • 写回答

2条回答 默认 最新

  • douyun4524 2013-12-06 14:08
    关注

    The following steps show the logical processing order, or binding order, for a SELECT statement. This order determines when the objects defined in one step are made available to the clauses in subsequent steps. For example, if the query processor can bind to (access) the tables or views defined in the FROM clause, these objects and their columns are made available to all subsequent steps. Conversely, because the SELECT clause is step 8, any column aliases or derived columns defined in that clause cannot be referenced by preceding clauses. However, they can be referenced by subsequent clauses such as the ORDER BY clause. Note that the actual physical execution of the statement is determined by the query processor and the order may vary from this list.

        FROM
        ON
        JOIN
        WHERE
        GROUP BY
        WITH CUBE or WITH ROLLUP
        HAVING
        SELECT
        DISTINCT
        ORDER BY
        TOP
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路