Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:38:02+00:00 2026-06-12T06:38:02+00:00

This is for Android SQLite. I have two queries like this: select * from

  • 0

This is for Android SQLite. I have two queries like this:

select * from table where name='name';

and

select * from table where name!='name' order by name;

I want to create a statement which combines these two queries. I tried union all but I can’t do order by one statement and then combine. I tried this:

select * from table where name='name'
union all
select * from table where name!='name' order by name;

All it did is to combine the queries and then order by name. I don’t want that. I want to do order by on the second statement first and then combine them.

To put the question differently, here is my data:

Name

a
b
c
d
e
f
g
h
i
j

But I want the output to be:

Name

g
a
b
c
d
e
f
h
i
j

I want to get one row to the top and then order the rest of the rows. Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:38:04+00:00Added an answer on June 12, 2026 at 6:38 am

    No need to use temporary tables, you need to add an additional column to sort on. Something like this:

    select 1, * from table where name='name'
    union all
    select 2, * from table where name!='name' 
    order by 1, name;
    

    I don’t have a sqlite install right now, but this trick should work. (you may have to add an alias to the first column).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want built a Android Application with a SQLite Database. I have two Java
everyone. This is a piece of code from using sqlite in android tutorial: return
My application have to load some points from internal sqlite database of android, and
I'm developing an Android application. I have a database table and I want to
This is about Android and SQLite database. Simply, I want to know, how can
I have a custom Android ContentProvider which stores and retrieves data from a SQLite
I'm working with the Android SQLite Database and I have two Tables in it.
I want to extract random rows from the app sqlite database in Android. I'm
I have this error: 12-07 15:27:11.567: E/AndroidRuntime(15797): Caused by: android.database.sqlite.SQLiteException: no such column: recipient:
I want to do the replication between sql server & android sqlite.I have done

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.