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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -