On Sat, 28 Mar 2009 09:42:59 +0000, Dermot
<paik...@googlemail.com> wrote:

>2009/3/28 Jay A. Kreibich <j...@kreibi.ch>:
>> On Fri, Mar 27, 2009 at 05:37:49PM +0000, Dermot scratched on the wall:
>>
>>> The statement is:
>>>
>>> SELECT COUNT(*) FROM products WHERE productid=808800033 AND
>>> (allowcountry2 & 0x0000000000000001)
>>> SELECT COUNT(*) FROM products WHERE productid=808800033 AND
>>> (allowcountry1 & 0x8000000000000000)
>>>
>>> I believe the allowcountry part is a bit pattern lookup but I can't
>>> find a definition for the & and so I am not sure what the statement
>>> does bar count the results.
>>
>>  To actually answer your question, yes, "&" in SQLite and some other
>>  DBs is a bitwise "and" operator, just like the C/C++ "&" operator.
>>  "|" is a bitwise "or".
>>
>>  It is my understanding that these operators are not part of the
>>  SQL standard, but a number of databases implement the operator.
>
>First off, sorry it was such an off-topic question. Thank you Jay for
>the answer.
>
>I can't find any reference to the ampersand's usage in my new book, my
>copy of learning MySQL or the SQLite Syntax documentation. I would
>have expected symbols to be listed before A in the index myself. There
>are references to bitmap indices. Symbols refer to the BNF notation
>but without reference to &. I have posted to SQLQueries.  Hopefully I
>can get an understanding of what that statement means from there.

For future reference, here's an explanation of all binary
operators, that is the

        -> [expr] -> (binary-operator) -> [expr] ->

part of the expr BNF diagram on 
http://www.sqlite.org/lang_expr.html

A few of those are bitwise.

pre-
ce-
den- opera-
ce   tor    operation
---- ------ ---------------
1    ||     concatenation
2    *      multiplication
2    /      division
2    %      modulo (remainder of integer division)
3    +      addition
3    -      subtraction
4    <<     bitwise shift left
4    >>     bitwise shift right
4    &      bitwise AND
4    |      bitwise OR
5    <      less than
5    <=     less than or equal
5    >      greater than
5    >=     greater than or equal
6    =      equal
6    ==     equal
6    !=     not equal
6    <>     not equal
6    IN     subset of
6    LIKE   case insensitive equality 
            with % and _ wildcards
6    GLOB   case sensitive equality
            with Unix style file globbing syntax
6    MATCH  reserved for user C function match()
6    REGEXP reserved for user C function regexp()
7    AND    boolean (logical) AND
8    OR     boolean (logical) OR


(Note to the SQLite developers: I could put this in the wiki
but it might be better to update the
http://www.sqlite.org/lang_expr.html#binaryops page itself)

> Again sorry for the post.

No problem.

>Dp.
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to