ios - SQLite select query. Get row with array -


i coder ios , use sqlite data storage.

for have 2 tables in database. table_1 , table_2 (it's easier understanding)

about struct:

table_1 contain id field (int type) , some_value field (text type)

table_2 contain id field (int type) , table_1_id field (int type)

my question next: how select row table_1 via array table_1_id field table_2, , must select order by. mean order array.

for example:

if table_2 -> table_1_id contain value 5, 1, 10, 3, 15, 2

the result of output must in order.

for query simple:

select * table_1 id in (5, 1, 10, 3, 15, 2)

but select not return order query return data order 1, 2, 3, 5, 10, 15.

i think make relation between table , make select table_2 uses order by, don't know how correct.

thanks in advance!

(very important me return order - 5, 1, 10, 3, 15, 2)

i find result in stackoverflow

link

this work me:

select * "comments" ("comments"."id" in (1,3,2,4)) order id=1 desc, id=3 desc, id=2 desc, id=4 desc

this hard code create query string programmatically in cycle , work great.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -