vendredi 15 juillet 2016

Group and Order By

I'm unsure if I'm using the GROUP BY function correctly, What I'm trying to achieve is for this query to select the latest input from the table and group them by the username, Below I have attached my query, the example database and the output I would like to achieve. SQL SELECT * FROM `test_pms` WHERE `username` = 'Lewis' GROUP BY `username` ORDER BY `id` DESC Database Structure Current Output Lewis | hi Desired Output Lewis | hi :) Hopefully I have outlined the issue I'm having with the GROUP BY I'm wondering If I'm using the ORDER BY incorrectly in accordance with the GROUP BY, Thankyou for any help.

Aucun commentaire:

Enregistrer un commentaire