How do I get the latest ID from the GROUP BY?
Right now, I made this:
SELECT * FROM (SELECT * FROM mycp GROUP BY ttype ORDER BY MAX(ID) DESC LIMIT 10) mycp WHERE PlayerName = 'Mark_Fletcher' OR fbk = 14 ORDER BY ID ASC
The output will be as show below.
The current table example:
==========================================
| ID | ttype | name
==========================================
| 1 | Business 1 | John
| 2 | Business 2 | Peter
| 3 | Business 3 | Steward
| 4 | Business 4 | Ethan
| 5 | Business 1 | Bob
| 6 | Business 1 | Patrick
==========================================
The current output:
==========================================
| ID | ttype | name
==========================================
| 1 | Business 1 | John
| 2 | Business 2 | Peter
| 3 | Business 3 | Steward
| 4 | Business 4 | Ethan
==========================================
What I wanted is this:
==========================================
| ID | ttype | name
==========================================
| 2 | Business 2 | Peter
| 3 | Business 3 | Steward
| 4 | Business 4 | Ethan
| 6 | Business 1 | Patrick //this become the latest Business 1
==========================================