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)
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.
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)