How to select specific data from listbox?

In MySQL, how do I select distinct records, but still select more data?

  • In MySQL, I want to select emails, firstname, date, etc from past orders where the email is unique. I then want to show other fields for that same row with the first match (the oldest) in the database. For example: Example Real Data: ID, Email, Name, ORDER DATE 1, [email protected] , Mark, 12-2-09 2, [email protected], Jim, 1-5-10 3, [email protected], Mark, 2-3-10 4, [email protected], Bob, 2-9-10 5, [email protected], Mark, 3-1-10 Of the above data, I only want it to show distinct my email, but the other info still there: Example Distinct Data: ID, Email, Name, ORDER DATE 1, [email protected] , Mark, 12-2-09 2, [email protected], Jim, 1-5-10 4, [email protected], Bob, 2-9-10 Do you know the correct MySQL query for this? Thanks!

  • Answer:

    SELECT ID,email,Name,MAX(ORDER_DATE) lastorder FROM table GROUP BY email

fiber at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.