I have 2 tables, one that is
usuarios and the other
usuarios_cuentas, both tables use
AUTO_INCREMENT for ids, in the table
usuarios the personal data of the users (name, surname, date of birth, sex) is saved and in the table
usuarios_cuentas the user's email and password are saved, but for that I need to get the id generated in the table
usuarios and assign it as a foreign key in the table
usuarios_cuentasHow do I get the last id generated?
I could immediately make another query based on the user's data to obtain the id, but in a table of users with thousands of records it may be that two people have the same name, surname, date of birth, sex, so that option would be discarded.
I found the following query to get the last id generated:
But this query gets the last id generated at the level of the entire database and I need to get the last id generated in a specific table.