Im using Android Sqlite and want to execute two queries and combine the result. Everything works fine if the sorting is done for the combined result. But i want the sort order for each query separate and then combine the result.
This is what i found from SQL: SELECT with UNION, ORDER BY and LIMIT and validated the query on http://sqlfiddle.com/#!5/98b6d/16 and works fine.
select * from (select * from supportContacts where (id=1) order by id asc)
UNION ALL
select * from (select * from supportContacts where (id!=1) order by RANDOM())
But how will i execute this query on android sqlite ContentResolver.query()
or is there any way using rawQuery
.
Note: I'm using this query to get all the audio files from Media Provider for MediaStore.EXTERNAL_CONTENT_URI
, but i know the id of a audio file , so my first query will get only single audio and second query will get all the audio excluding the known audio id.