I have 2 queries I can run and will get 2 totally different results, solely because I use a “sideways single quote” versus a single quote. See below:
SELECT * FROM items WHERE 'natural' IS NOT NULL
Will return every record regardless if the “natural” column is set to NULL
SELECT * FROM items WHERE `natural` IS NOT NULL
Will correctly only return records where there are values set for the column “natural”
That ain’t right.
Your first example
'natural' IS NOT NULLtests to see if the string literal'natural'is not null. Since string literals are always not null, this condition will always be true.The second example tests the value of the column with the name
natural. This is what you want.Related
String literals
Schema object names