On 2016/08/17 11:04 AM, Simon Davies wrote:
On 17 August 2016 at 09:39, R Smith <rsm...@rsweb.co.za> wrote:
On 2016/08/17 9:05 AM, flo wrote:
Hi everyone,
.
.
.
Well, it is perfectly valid to give boolean operations as an expression.
If I said " id = 3 AND 6 then the resulting value would be 2 (If you are
unsure why that is you need to read up on Boolean logic, check google for
it)
Boolean AND:
sqlite> select 3 and 6;
1
Bitwise and:
sqlite> select 3 & 6;
2
Indeed - thanks Simon.
I wasn't actually thinking in SQL terms there, just trying to explain a
principle - which I should have checked to be clear on to the OP.
To be sure - "bitwise" isn't something else, it is still Boolean, it's
just a way of doing boolean logic per bit (what makes the world of
computing possible) as opposed to regarding the input as a single entity
that evaluates to TRUE or FALSE. The fact that 3 and 6 both evaluate to
TRUE (Because >0) in SQLite means they are regarded as entities (as they
should when you use the word "AND" in stead of "&") and so rightly
evaluate to TRUE (1) as above.
As an aside - I come from programming languages where that difference
did not exist and "(3 and 6) --> 2", and "((i>0) or 2) -> 3" where i>0,
which made setting flags and such much much faster and is much better to
my mind with the small caveat that you couldn't hide error-return values
in Boolean guise or directly refer a return value that might have
multiple possible values (but you only want to know if it is or isn't
so) which is a better construct for SQL.
In those days bytes were expensive. Now you can dedicate Integers or
even strings and a whole column to one flag state without feeling any
guilt - viva progress! :)
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users