Re: [sqlite] Using Bitwise Logic In Query

2016-09-08 Thread Matthias-Christian Ott
On 2016-09-08 12:17, Paul Sanderson wrote:
> How does this work for you to get all the even rows
> 
> SELECT ROWID
> FROM table
> WHERE ROWID & 0x01 = 0x00

I think you should be able to create an expression index as well:

https://www.sqlite.org/lang_createtable.html#rowid

- Matthias-Christian

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using Bitwise Logic In Query

2016-09-08 Thread Clemens Ladisch
Simon Slavin wrote:
> ... if your table has lots of rows and/or you do lots of queries like
> this, you should consider keeping a copy of the lower 16 bits as
> another integer column.

In these case, you should consider using an expression index:

sqlite> create table t(x,y);
sqlite> create index tx on t(x & 0x);
sqlite> .eqp on
sqlite> select * from t where x & 0x = 42;
--EQP-- 0,0,0,SEARCH TABLE t USING INDEX tx (=?)


Regards,
Clemens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using Bitwise Logic In Query

2016-09-08 Thread Paul Sanderson
How does this work for you to get all the even rows

SELECT ROWID
FROM table
WHERE ROWID & 0x01 = 0x00


Paul
www.sandersonforensics.com
skype: r3scue193
twitter: @sandersonforens
Tel +44 (0)1326 572786
http://sandersonforensics.com/forum/content.php?195-SQLite-Forensic-Toolkit
-Forensic Toolkit for SQLite
email from a work address for a fully functional demo licence


On 8 September 2016 at 11:07, Dave Blake  wrote:
> Looking for the best way to query a table with an integer column by value
> of the lower 16 bits of the data in that column. Does SQLite support
> bitwise logic?
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using Bitwise Logic In Query

2016-09-08 Thread Simon Slavin

On 8 Sep 2016, at 11:07am, Dave Blake  wrote:

> Looking for the best way to query a table with an integer column by value
> of the lower 16 bits of the data in that column. Does SQLite support
> bitwise logic?

Yes.  You can use the following

& | ~ << >>

AND OR NOT SHIFTLEFT SHIFTRIGHT

However it is far faster to search for integer values.  So if your table has 
lots of rows and/or you do lots of queries like this, you should consider 
keeping a copy of the lower 16 bits as another integer column.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Using Bitwise Logic In Query

2016-09-08 Thread Dave Blake
Looking for the best way to query a table with an integer column by value
of the lower 16 bits of the data in that column. Does SQLite support
bitwise logic?
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users