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

  • Home
  • SEARCH
  • 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 4569144
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:10:36+00:00 2026-05-21T19:10:36+00:00

I have this table: I want to search by UID ID | VID |

  • 0

I have this table: I want to search by UID

ID | VID | UID
1  |  1  | 5
1  |  1  | 6
1  |  2  | 6
2  |  3  | 5
2  |  3  | 6
2  |  4  | 6

I want to end up with this result:

ID | VID | UID
1  |  2  | 6
2  |  4  | 6

In other words, only select the entries where the VID is MAX of the UID but keeping in min NID could differ. Something like this I suppose:

select * from TABLE where uid = 6 and max(vid)

???

But this doesn’t work?

  • 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-05-21T19:10:37+00:00Added an answer on May 21, 2026 at 7:10 pm

    One way is to order by the value in descending order (so the max is at the top), then just select the first result.

    SELECT t.ID,
           t.VID,
           t.UID 
    FROM table t 
    WHERE t.ID = 1 
    ORDER BY t.VID DESC 
    LIMIT 1
    

    Or do you mean you want all rows where t.VID is the highest value? In which case you could do something like this,

    SELECT t.ID,
           t.VID,
           t.UID
    FROM table t
    WHERE t.ID = 1
          AND t.VID = (SELECT MAX(VID) FROM table);
    

    EDIT: Based on the edit to your question, it looks like you just want the max VID value for each ID? If I’m understanding you correctly, then this should give you what you need.

    SELECT t.ID,
           max(t.VID) as VID,
           t.UID 
    FROM table t 
    WHERE t.UID = 6 
    GROUP BY t.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to search the computer from this table and when i have stored
I have this big table which I want to have fulltext search, so I
Suppose we have a table with collumns (A,B,C) We want to search this table
I have this table: User id INT PK login VARCHAR UNIQUE I want to
I have this JSF table. I want to add row numbers. <?xml version=1.0 encoding=UTF-8?>
I have this JSF table which is used to display data. I want to
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I have a table and this table contain multiple columns. I want to know
I have query to show the table like this: but I want to PIVOT
I have an SQL table like this : sales(product,timestamp) I want to display a

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.