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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:56:12+00:00 2026-06-15T22:56:12+00:00

Very quick one: I’ve done this before, but having a bit of a mind

  • 0

Very quick one:

I’ve done this before, but having a bit of a mind blank right now.

SELECT max(id) as id, username, email 
FROM user_info 
WHERE username!='' 
GROUP by id,email

Unfortunately this is not working. It will select the max id but not then the corresponding data from that row.

  • 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-15T22:56:13+00:00Added an answer on June 15, 2026 at 10:56 pm

    If you have multiple ids per email address, then you can use max(id) and group by the email only.

    SELECT max(id) as id, username, email 
    FROM user_info 
    WHERE username <> '' 
    GROUP by email, username 
    

    You can use a subquery which will return the max id in the subquery and then you use that to self join on the table to return the most recent id, username and email:

    SELECT u.id, u.username, u.email 
    FROM user_info u
    INNER JOIN
    (
      select max(id) maxid, email
      from user_info
      where username <> '' 
      group by email
    ) u2
      on u.id = u2.maxid
    

    See SQL Fiddle with Demo

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

Sidebar

Related Questions

I asked this question earlier and I got very quick and helpful responses: Linq
Quick one; am I right in thinking that passing a string to a method
Quick one: I'm still a NetBeans amateur, however I've grown very fond of it
Hopefully a very quick question. In one of my functions I want to generate
I have a database to store people's quick links. This is a very basic
the answer to this could be easy. But I'm very fresh to programming. So
This is a very quick (and probably noob) question. I am creating a dependencyobject
very quick one, I was always wondering, do internet browsers use for rendering OS
Take the following string as an example: The quick brown fox Right now the
Here's a very quick example for my problem: http://img19.imageshack.us/img19/3575/workertool.png (I'm not allowed to post

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.