On 2/3/2014 12:25 PM, Adam Devita wrote:
This query:
SELECT id, data_blob FROM data WHERE timestamp = (SELECT MIN(timestamp)
FROM data WHERE stream_num = ?) LIMIT 1
seems to occasionally produce a wrong result (the content of data_blob is
incorrect given the values of stream_num)
yet this query
SELECT id, data_blob FROM data WHERE stream_num = ? order by timestamp asc
LIMIT 1
seems just fine
If timestamp is not unique - if there is more than one record carrying
the smallest timestamp - then these queries might produce different rows.
The first query doesn't even restrict the result to a particular
stream_num. If you have two records with the same timestamp but
different stream_num, then the first query might return the "wrong" one
(one where stream_num does not equal the bound parameter). The second
query is only ambiguous if there are two records with the same timestamp
and the same stream_num.
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users