0

I have a MySQL table like this:

id | num | name
1  | 102 | name 1
2  | 102 | name 2
3  | 102 | name 3
4  | 103 | name 4
5  | 103 | name 5
6  | 103 | name 6
7  | 103 | name 7

I want to know how its possible to get the latest "num" values (sorted by ID column), so the output should look like:

id | num | name
3  | 102 | name 3
7  | 103 | name 7

Without the rest of the rows in this table.

3
  • You have tagged [php]. If that is the query language you are using, it is off topic here. You need to improve the quality of your post so it can be migrated to the proper site. You need to share what you have already tried to and give examples of your code so people don't think you are looking for a free coding service.
    – CharlieRB
    Oct 6 '17 at 19:59
  • You say "Without the rest of the columns in this table." You mean "Without the rest of the rows in this table," right?
    – Scott
    Oct 7 '17 at 8:50
  • 1
    Probably a combination of GROUP BY and MAX().
    – Seth
    Oct 7 '17 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.