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 8947017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:38:43+00:00 2026-06-15T12:38:43+00:00

My table: id | elite | pos 1 | 0 | 9 2 |

  • 0

My table:

id | elite | pos
1  |   0   |  9  
2  |   1   |  8
3  |   0   |  7
4  |   1   |  6
5  |   0   |  5
6  |   1   |  4
7  |   0   |  3
8  |   1   |  2
9  |   0   |  1
10 |   1   |  0

I have this simple query

SELECT id, elite FROM tbl LIMIT 0, 5 ORDER BY pos DESC

It will return the id 1 2 3 4 5. Over time, these values were to change. The result must have always a count of 5, however if on the result there are at least one id with an elite >= 1, the result must not contain any more id with an elite having the 1 value. So the result must not contain id having more than one elite >= 1.

Is this possible within a query?

  • 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-15T12:38:46+00:00Added an answer on June 15, 2026 at 12:38 pm

    You can use UNION to combine two queries, like so:

    (SELECT * FROM tbl WHERE elite = 1 LIMIT 1)
    UNION
    (SELECT * FROM tbl WHERE elite = 0)
    ORDER BY pos DESC LIMIT 5
    

    It will give the results you need.
    Check out Mysql reference for UNIONs

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

Sidebar

Related Questions

i have two table like this <table> <tr> <td> <select name=prueba id=prueba class=ddlStyles> <option
I am very lost with this Regex. I have a HTML Table with 3
Table #1: qa_returns_items Table #2: qa_returns_residues I have a long time trying to get
Having a problem with returning results from one particular table in a database. I
I have a Table with 4 columns inside a FlowDocument. I've set the width
I want two tables to have the same height. If the left table contain
I'm trying to translate code from this thread in python: import sys from PyQt4.QtCore
I have a MySQL table with a field named description , with a record
I have an HTML table in my page that I'm trying to replace with
To Set up the scenario, Lets say I have 100000 rows in the table

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.