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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:10:00+00:00 2026-06-02T05:10:00+00:00

Okay the title may not justify what I’m trying to do here but dont

  • 0

Okay the title may not justify what I’m trying to do here but dont know my problem well enough to explain it perfectly.

What i’m trying to do:

I need to retrieve rows from a MySQL data base where response = 8 or 9 but display the newest entry if there are multiple matches. Let say I have 6 rows and 1 rows have response = 8 and 2 row where response = 9 I want to retrieve the newest entry based on row id.

example:

row1 id=12 user_id = 15 response = 8

row2 id=11 user_id = 15 response = 9

row3 id=10 user_id = 15 response = 1

row4 id=09 user_id = 15 response = 9

row5 id=08 user_id = 15 response = 4

row6 id=07 user_id = 15 response = 5

I want to retrieve row1 since it’s the newest entry where response = 8 or 9

I tried but failed:

SELECT a.id, MAX(a.response) FROM user a WHERE a.user_id = $userID AND a.response IN (8,9) GROUP BY a.user_id

Thanks in advanced.

  • 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-02T05:10:02+00:00Added an answer on June 2, 2026 at 5:10 am
    SELECT u.id, u.user_id, u.response
    FROM user u
    WHERE u.id in 
    (
     SELECT max(id) FROM user WHERE user_id = $userID  and response IN (8,9)
    ) ;
    
    
    
    
    ID  USER_ID RESPONSE
    12  15  8
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay the question title may not have made sense... mostly because I don't know
Okay, this may seem silly, but on an ASP.NET .ascx control, I'm trying to
Okay so the title may be a bit misleading. What I am trying to
Okay that's probably not the best title, I know why we need browser resets:
Okay. Here's the code. XML Parsing Error: not well-formed <item_to_page_title><![CDATA[Breaking news, real-time scores and
Okay, I'll admit - the title is not the most descriptive/helpful but I couldn't
Okay the title cannot explain the situation correct enough. Now this is it, I
Okay, I know that is a funky-sounding title, but I couldn't think of a
Okay so the title might sound a bit confusing, but here's what I want
Okay this may sound silly, but I am not very familiar with XML. What

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.