mysql - Retrieve last inserted id based on column PHP -
this question has answer here:
i'm looking able retrieve last inserted id based on username. know within pdo able use use lastinsertid() can tell gets last 1 inserted no other parameters. possible in short , simple?
the way thought using like
select id table_name username=:username order enteredtimendate asc
would easiest way this?
edit address duplicate issue. "original" question question considered duplicate of asks how retrieve last inserted id, question retrieving last inserted id based on parameter.
use following query last inserted id:
select id table_name username=:username order enteredtimendate desc limit 1;
data sorted based on enteredtimendate in descending order , picking first row limiting query result.
Comments
Post a Comment