I will explain this using the equivalent ANSI JOIN syntax:
Option 1
SELECT * FROM TXN LEFT JOIN CHK ON TXN.CHK_ID = CHK.CHK_ID WHERE TXN.CURRENT = 'Y' AND CHK.CURRENT = 'Y'
Option 2
SELECT * FROM TXN LEFT JOIN CHK ON TXN.CHK_ID = CHK.CHK_ID AND CHK.CURRENT = 'Y' WHERE TXN.CURRENT = 'Y'
As you can see, in option 1, your constant predicates are applied after the expression of the LEFT JOIN table is specified, i.e. LEFT JOIN result.
In option 2, one of your constant predicates is part of the LEFT JOIN expression.
How does LEFT JOIN ?
The idea behind the LEFT JOIN is that it will return all the rows from the LEFT side of the JOIN expression, regardless of whether the corresponding line exists on the other side, given the join predicate. So, in option 2, regardless of whether you find the string CHK with CURRENT = 'Y' for the string in TXN , the string in TXN still returns. This is why you get more lines in option 2.
In addition, this example should explain why you should prefer the ANSI JOIN syntax. In terms of service / readability, itβs much more clear what your request is doing.
source share