Is the everything-is-arithmetic MySQL specific? Today I learned that SELECT f1,EXISTS(SELECT ...),f2 is valid in MySQL and, reading from StackOverflow, apparently in PostgreSQL as well and the EXISTS part is 0 when the subquery result is empty and 1 when the result is not. Then I began to think and tested a few queries looking like SELECT * WHERE column1 - column2 and even this worked and it's the same as column1 &lt;&gt; column2. And I even tried WHERE (column1 &gt; 0) - column2 and even this worked. Is this SQL standard or just MySQL is trigger happy about casting booleans and integers with wild abandon? Or perhaps booleans do not even exist in SQL and 0 / 1 represents them?
Or perhaps booleans do not even exist in SQL and 0 / 1 represents them


boolean do exists in the SQL standard but as "real" booleans. 

So valid boolean literals are false or true. 


  Is this SQL standard or just MySQL is trigger happy about casting booleans and integers with wild abandon


MySQL does not actually support boolean values. It simply treats anything that can't be converted to a non-zero number as "false". 

E.g. 

select *
from some_table
where 'xxxx';


is accepted as valid (even though it is invalid SQL) and is equivalent to where false because xxxx can't be converted to a number and thus is assumed to be 0 which is treated as false. 

On the other hand

select *
from some_table
where '42xxxx';


is treated as where true because 42xxx will be (implicitly) converted to 42 which in turn is treated as "true". 



The query:

SELECT * 
WHERE column1 - column2


is invalid standard SQL because it yields a number (assuming column1 and column2 are numbers) and a number is not a boolean expression.



You can see this behavior when doing: 

select 1 &gt; 0;


MySQL returns the number 1 whereas a database supporting real booleans (e.g. Postgres) will return true. Oracle does not support real booleans so select 1 &gt; 0 from dual is actually invalid there.