Matthew Jones <matthew.jo...@hp.com> wrote:
> From a web search (and abbreviated):
> 
>>> I have BLOBs in my schema and the data will often start with bytes of
>>> 0 value.
>>> I'm having a tough time coming up with the proper SQL syntax to
>>> select all the columns that start with 2 0's (or any zeros).
> 
>> SELECT * FROM mytable WHERE myblob LIKE X'0025';
>> SELECT * FROM mytable WHERE quote(myblob) LIKE 'X''00%';

Another approach:

SELECT * FROM mytable WHERE substr(myblob, 1, 1) = X'00';

> Now I have a column of blob data (always 20 bytes) and I would like to
> do a LIKE select on this column where I have the first 10 bytes but they
> can be any value including, of course, the % character. Is this possible
> or does the arbitrary nature of the data make this infeasible?

SELECT * FROM mytable WHERE substr(myblob, 1, 10) = ?;

-- 
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to