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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -