I have difficulty understanding SELECT * FROM myTable WHERE 0 = ... in the following SQL statement.
SELECT * FROM myTable WHERE 0 = (SELECT COUNT(*) FROM incTable
WHERE myTable.export_date <= incTable.export_date
AND myTable.colA = incTable.colA
AND myTable.colB = incTable.colB
AND myTable.colC = incTable.colC)
From my understanding, usually in the WHERE clause, a column is evaluated against some other entity (i.e. another column or value). What does it mean to be evaluating against two numbers (i.e WHERE 0 = 5)? Will SELECT * FROM myTable always return the contents of myTable regardless of what the outcome of the WHERE clause in the above SQL statement?
0=5 would be false for “all” rows, so wouldn’t return anything. If the subquery doesn’t return any rows, you’ll get all the rows in myTable.
This is a weird way of doing EXISTS().