The WHERE clause takes only one parameter.  WHERE expects an expression, which 
evaluates down to one value.  That expression does not need to be a comparison. 
 It commonly is, but it can be anything, such as a CASE expression, an EXISTS 
subselect, or a function.

As far as SQLite cares, all three of these are identical… and I mean completely 
identical, once you evaluate the constants:

sqlite> SELECT 'true' WHERE 1;
true
sqlite> SELECT 'true' WHERE 2 - 1;
true
sqlite> SELECT 'true' WHERE 1 = 1;
true
sqlite> SELECT 'true' WHERE 0 = 0;
true

Don’t believe me?  Consider the value of the expression “1 = 1” or “0 = 0”:

sqlite> SELECT 1 = 1, 0 = 0;
1|1

So in the clause “WHERE 0 = 0" the expression “0 = 0” evaluates to the integer 
“1”, which is passed to the WHERE clause, considered true, and the row is 
returned.  All the WHERE clause ever sees is “1”.  It doesn’t care that the 
value was derived from a comparison, because that is totally irrelevant.  WHERE 
only cares that there was an expression that evaluates to a value that is 
considered equivalent to “true”.


  -j



On May 5, 2014, at 12:31 PM, Petite Abeille <[email protected]> wrote:

> 
> On May 5, 2014, at 7:15 PM, Stephan Beal <[email protected]> wrote:
> 
>> Why expect an error? It's abstractly the same as saying WHERE 'a' = 'b’,
> 
> I mean ‘where 1’, or ‘where ‘1 - 1’, or ‘where null’, or ‘where 0 / 0’, or 
> any of this nonsense. There is nothing to compare. It’s nonsensical. 
> 
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

--  
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it, but showing 
it to the wrong people has the tendency to make them feel uncomfortable." -- 
Angela Johnson




_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to