Is there a difference in the following comparisons
#1
where x = true
#2
where x is true
#3
where x = '1'
#4
where x
This is exactly the same as
WHERE x
It is TRUE, FALSE or NULL exactly when x is.
This is the same as the first case, except when x is NULL, in which case it will be FALSE. So it is the same as
WHERE coalesce(x, FALSE)
This happens to be the same as the first case, since '1' is interpreted as TRUE. See the documentation:
The datatype input function for type
booleanaccepts these string representations for the “true” state:
true
yes
on
1
My preferred way is the simplest:
WHERE x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With