How do i select this

Hi, can i ask some question, I know how to get the last inserted id if the field is auto_increment…now my problem is that how can i get the last inserted id which is not auto_incremented…? is there a function or do i need to issue an PDO select statement ?

let says this is my table name “student” the std_id is not auto_increment but i set as primary key,the last issue for inserting statement is std_id = ‘8’,how can i get that value 8 because i am going to insert it to other table,do i need to select first ?but how can i select the last row ?

  std_id              std_name      std_age
    5                   mike             18
    8                   jean              26  

Thank you in advance :slight_smile:

If the id is not auto incremented then the code knows the last ID it inserted because it assigned that id to the last insert query. :wink:

You could add each insert id to a stack and know the whole history.

Am I missing something?

Hi, Thank you it solved my problem :slight_smile: