I am trying to determine that standard SQL behaviour for comparing a number to a character or string version of the same number. Does SELECT 1 = '1' (or the like) always return some sort of “truthy” value (true, 1, 't', etc.)? I have confirmed as much on PostgreSQL and MySQL, but I cannot find a resource for SQL as a whole.
Update: The purpose for the question is that I’m trying to figure out if using a number, without the quotes, will work when selecting/inserting/updating/etc. from a non-numeric field whose value is a number.
SELECT 1='1'givesTRUEsince'1'is a correct constructor forINTin all implementation known to me.But SQL uses strict typing, see that:
Regarding the standard (SQL 92, 99 & 2003) it seems to be wrong:
because
<quote>is only contained in<bit string literal>,<hex string literal>, … but not in numeric literals…