In the past few days, I've seen people show example code like this:
WHERE 1=2
when you want the conditional expression to be guaranteed to be false. I believe you could also simply write:
WHERE FALSE
because the syntax is something like:
WHERE <expression>
and, I believe, in this context <expression> includes not only a clauses with operators, but simple constants.
I think that, under-the-hood, the SQL parser is looking for an expression, for each row, that evaluates to a Boolean, perhaps after some type conversion. FALSE meets this requirement. It may also be possible to use 0 instead of FALSE because, in many languages, when 0 is coerced to a Boolean, it becomes FALSE.
In general, whenever there is a place in the syntax of a language that specifies an expression of some sort, a constant is considered a valid expression.
Just thought I'd add my 2 cents. Take what you like and leave the rest.
Regards,
Paul Strauss
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (1) |
Tidak ada komentar:
Posting Komentar