javascript - "Union" with "order by" and "limit" in sqlite not working -
i developing mobile application , store data offline uses local database using sqlite. in order synchronize local database remote database, querying last 10 favorites, , last 10 match. using following query:
select user_id users is_favorite>0 order is_favorite desc limit 10 union select user_id users is_auto_match>0 order is_match desc limit 10
note below query working fine,which confirm there no error in local database:
select user_id users is_favorite>0 union select user_id users is_auto_match>0
order not allowed inside compound queries; place allowed @ end of entire query, affects all records.
to able use order 2 individial queries, have to use subqueries:
select * (select user_id users is_favorite > 0 order is_favorite desc limit 10) union select * (select user_id users is_auto_match > 0 order is_match desc limit 10)
Comments
Post a Comment