Andrea Federico Grisotto
<[EMAIL PROTECTED]> wrote:
CREATE TABLE np (
  fromId        VARCHAR(6),
  toId          VARCHAR(6),
  serviceId     INTEGER,
  PRIMARY KEY (fromId, toId)
);

if I run this query in *sqlite version 3.3.6* I obtain (two rows):


sqlite> SELECT * from np WHERE (42>=fromId) AND (42<=toId);
fromId           toId             serviceId
---------------  ---------------  ---------------
0                5                2
40               43               3

I believe this is what happens. You've declared the two columns to have TEXT affinity (see http://sqlite.org/datatype3.html), so comparisons are done in alphabetical order, not in numeric order. When compared as strings, '0' < '42' and '5' > '42'.

If you want fromId and toId to be treated as integers, why don't you declare them as INTEGER?

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to