我擁有帶id,unique_id和order_number的表。從每個GROUP BY(unique_id)和ORDER BY編號選擇具有MAX ID的行
- 我通過UNIQUE_ID
- 我想借此從每個組
- 而最後一件事,我想那種由ORDER_NUMBER行
我也有MAX ID行希望將行幾個WHERE子句。這是我嘗試不工作:
SELECT MAX(id) AS id
, order_number
FROM table
WHERE final = 0
AND username = '$username'
AND active = 1
GROUP
BY unique_id
ORDER
BY order_number
''redni_broj'與'unique_id'相同嗎? – Strawberry
GROUP GROUP by unique_id ... hmmm – Mihai
對不起,我已編輯帖子。它應該是order_number – user3100193