sqlite3 - SQLite select multiple rows using id -
i not sure if there kind of technical limitation or if losing mind. trying query specific rows sqlite database using , conditions on ids of rows want. query not returning results , causing logger throw error stating there syntax error.
here query:
select * equipment id = 2 , id = 3 , id = 4 , id = 7 , id = 11 , id = 34
and here syntax error log:
aug 17 2017 23:12:23 [err]: err002 - query on equipment not prepared: near "=": syntax error @ file: c:\users\geowil\documents\visual studio 2015\projects\ov_pocs\universearc_poc\datasystem.cpp line: 323.
so, sailed on sqlfiddle try , see if missed something. link below. displaying same behavior, , conditions returns no results running queries on single ids or range of ids works.
http://sqlfiddle.com/#!5/68cd3f/4
am doing wrong or limitation of sqlite?
update:
had brain wave. using id in(1,3,4) works on sqlfiddle want repurpose question asking why works original query did not.
use "in" select multiple tuple. select * equipment id in (2, 3, 4, 7, 11, 34);
. every tuple selected if every ids existed in sqlite or database.
for query, logical equation never select 1 of tuple because id won't have 2 or more values (id=2 , id=3
: if id
equal 2
won't equal 3
). in case must use or
instead of and
. select * equipment id=2 or id=3 or id=4 or id=7 or id=11 or id=34;
. every tuple selected if every ids existed in sqlite or database.
Comments
Post a Comment