Where to put conditional expressions in ANSI syntax SQL queries

What is the difference between these two queries? I was resistant to jumping on ANSI syntax because I could not figure out the various syntax ambiguities.

Is 1) a return of the join product and only then filters out those combined records that have weight> 500? And 2) filter out those that were before accession?

Is there 2 bad syntax? Why can I use this?

1

SELECT SOMETHING
FROM FOO
INNER JOIN BAR
ON FOO.NAME = BAR.NAME
WHERE BAR.WEIGHT < 500

2:

SELECT SOMETHING
FROM FOO
INNER JOIN BAR
ON FOO.NAME = BAR.NAME AND BAR.WEIGHT < 500
+3
source share
6 answers

"1) returns the connection product and only then filters out those combined records that have weight> 500? And 2) filter out those that were before the connection?"

true, , , 2) , . . otoh .

: (, , ) . , proccessor, . , , ...

+5

, inner join, . # 1, , , . ON , , , .

outer joins, - BAR.WEIGHT < 500 .

+3

, , , 1) 2) ; . EXPLAIN PLAN , .

, , ? ANSI, , .

.

0

2 ? ?

JOIN WHERE, Oracle. Oracle :)

, JOIN WHERE, , . :

SELECT dept.name, SUM(emp.salary)
FROM   dept
JOIN   emp
       ON dept.deptno = emp.deptno
          AND emp.commission IS NULL
WHERE  dept.region = :region
GROUP BY dept.name;

, . emp.commission JOIN, , " " - . dept.region WHERE, , , .

, , . , , . JOIN "" , WHERE, .

0

WHERE .

ON .

, , .

INNER JOIN , ( ). outer join.

:

    • INNER JOIN outer join. .
    • .
    • . . ( WHERE) .
  • Readable: .
0

Source: https://habr.com/ru/post/1749280/


All Articles