How to return only the same (but last) values in the loop (PHP)

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.

Answer

Attribution
Source : Link , Question Author : John Siemens , Answer Author : Community

Leave a Comment