How do I get max id of each user data in the table

Hi guys,

I’ve database query like below:

SELECT
	id, uid, pho_path
FROM
	photo
WHERE
	uid = :user_id
ORDER BY id ASC

How do I get the id of the latest row.

Thank you,

your code example filters the results for a specific uid

thus, this is all you need –

ORDER BY id DESC LIMIT 1

the title of your thread, though, asks for something else

Thank you,
Sorry for the question. I was confused how it works. So I can’t think of it clearly :blush:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.