I have Some data in SQLite database in android. I want to retrieve data from database using WHERE clause Using LIKE and NOT LIKE Conditions. I am combining two statements using UNION ALL Command. For that the queries are
SELECT * FROM TABLENAME WHERE column_name LIKE SOMTHING.
This will return some rows. and then i am writing query
SELECT * FROM TABLENAME WHERE column_name NOT LIKE SOMTHING.
this will return remaining rows.
I want returned items of first query at first then 2nd query items afterwards. This can be achieved by using UNION ALL command. So Query is Like
db.rawQuery("SELECT * FROM TABLENAME WHERE column_name LIKE SOMTHING UNION ALL SELECT * FROM TABLENAME WHERE column_name NOT LIKE SOMTHING")
But I want 2nd query items in sorted order along with and after first query item/items. So i wrote the Query like
db.rawQuery("(SELECT * FROM TABLENAME WHERE column_name LIKE SOMTHING) UNION ALL (SELECT * FROM TABLENAME WHERE column_name NOT LIKE SOMTHING ORDER BY column_name)")
I NEED ALL DATA FROM THAT TABLE BUT FIRST I WANT ROWS RETURNED BY FIRST QUERY THAT NEED NOT TO BE SORTED, BUT AFTER THOSE ROWS i WANT ALL ROWS(where not like) IN SORTED ORDER, I am getting all data in a sorted form, at first position it is not returning rows for first query(before union all)
can any one help me on this. Thanks in advance.