Procedurally transform subquery into join

前端 未结 7 1493
有刺的猬
有刺的猬 2020-12-05 14:34

Is there a generalized procedure or algorithm for transforming a SQL subquery into a join, or vice versa? That is, is there a set of typographic operations that can be appli

7条回答
  •  天涯浪人
    2020-12-05 15:15

    At a really high level. to transform a sub-query to a JOIN:

    1. FROM: Table Names go into FROM
      • JOIN The parts of the WHERE clause with table names on both sides determine (a) the type of JOIN (b) the condition of join
      • WHERE The parts of the where clause without table names on both sides go into the WHERE clause
      • SELECT Column names from Sub-Query go into the SELECT

    Transforming a JOIN to Sub-Query entails the reverse of the above logic

提交回复
热议问题