Question

How cand I put the following two MySQL SELECT statements in one PHP query?

$SQLquery = "SELECT MAX(ID) AS last_id FROM table";
$SQLquery = "SELECT full_name FROM table";

Thanks, and a nice day.

Was it helpful?

Solution

You can get the latest record without using MAX,

SELECT  *
FROM    tableName
ORDER   BY ID DESC
LIMIT   1

But if you certainly want to use MAX

SELECT  *
FROM    tableName
WHERE   ID = (SELECT MAX(ID) FROM tableName)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top