user2940737
user2940737

Reputation: 1

Using ORDER BY with WHERE IN

In my SQLite query:

"SELECT * FROM menu WHERE ID IN (" & optList & ") ORDER BY seqno"

optList is a list of ID's and something like:

"01","02","14","03"

The corresponding seqno values for these rows are: 01 02 03 04 and this is the order I need to have but the rows returned are in ID order, i.e. 01, 02, 14, 03

Does the ORDER BY not work when using WHERE IN and/or is there some other way of returning the rows in the desired order?

Upvotes: 0

Views: 114

Answers (1)

jai lalawat
jai lalawat

Reputation: 73

This worked fine for me

SELECT *
FROM `accolades`
WHERE id
IN ( 1, 3, 4, 5 )
 order by id asc

Upvotes: 1

Related Questions