On Fri, May 2, 2014 at 2:47 PM, David King <dk...@ketralnis.com> wrote:
> > Quick, without trying it out, what would you expect the following > statement to return: > > select 1 where 1 - 1; > > (a) one row > > (b) no row > > (c) syntax error > > For extra entertainment, try some variations: > > select 1 where 1; > > select 1 where 0; > > etc... > > Bonus points for a rationalization of any of the behaviors you see or > don’t see. > > I'm not sure why this is surprising. sqlite happily uses 1 and 0 as > booleans: > > sqlite> select 1 = 1; > 1 > sqlite> select 1 = 100; > 0 > > And the WHERE clause is just a boolean expression. Your expressions are > simply "select the literal 1 where true" or "where false" which will either > cause the value to be selected or not, just due to the WHERE clause. > > Am I missing something? > I'm guessing that Mr. Abeille is upset that SQLite uses integers as booleans, the same as C++ does, whereas other SQL database engines have a distinct boolean type that is incomparable with integer. -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users