0

I have recently come up with an interesting result in SQL. Probably not that interesting, but my inability to process the inner workings of this make it such.

What happened was, when I ran the following query on a mysql database.*

SELECT 1= 'string',0='string';

the results were as follows.

1= 'string'|0='string'|
-----------|----------|
          0|         1|

So, would appreciate if someone can unravel the inner workings of the boolean operations in SQL which yield the above results. Thanks

PS: the reason why I ran the query was, a query builder function I wrote returned a query in the following format and the result set was inverted from the expected.

SELECT * FROM table WHERE column IS NOT NULL = 'string';

The result set included results where the column was in fact NULL. (giving the hint that all 0 values in IS NOT NULL part of the query were compared against the string and collectively returned true in that part of the WHERE clause)

shehan.k
  • 17
  • 1

0 Answers0