MAX (id) function with MySQli How can I use the following statement to return only the record with the maximum PersonID from the table?

/* Create the prepared statement */
if ($stmt = $mysqli-&gt;prepare("SELECT Max(PersonID) AS PersonID,familyname,firstname,othernames,gender,CountryID,dateofbirth,nrcno,passportno,address,occupation,village,chief,district,StatusID,imgurl

FROM t_persons")) { 

/* Execute the prepared Statement */
$stmt-&gt;execute();

/* Bind results to variables */
$stmt-&gt;bind_result($PersonID,$familyname,$firstname,$othernames,$gender,$CountryID,$dateofbirth,$nrcno,$passportno,$address,$occupation,$village,$chief,$district,$StatusID,$img);

/* fetch values */
while ($rows = $stmt-&gt;fetch()) {
 // display records in a table
in PostgreSQL you could use use something called "windowing and analytics". this does not exist in MySQL however.
an alternative way would be to use GROUP BY and do ..
SELECT max(id), person, address, ... FROM tab GROUP BY person, address, ...
this should work somewhat efficiently if you need it for all. if you need it for jsut one folk you should go for ypercube's answer.