[DiscordArchive] what am i supposed to do when i want to run insert query and i need to know id of that row ?
[DiscordArchive] what am i supposed to do when i want to run insert query and i need to know id of that row ?
Archived author: Rymercyble • Posted: 2023-11-25T20:35:15.817000+00:00
Original source
what am i supposed to do when i want to run insert query and i need to know id of that row ?
Archived author: Young Toto • Posted: 2023-11-25T21:18:50.333000+00:00
Original source
The id of the row you just inserted? I know python has a function to get that, not sure about cpp
Archived author: Young Toto • Posted: 2023-11-25T21:19:18.348000+00:00
Original source
Worst case, you can select all, order by the id in descending order, and limit the select to 1 row
Archived author: Young Toto • Posted: 2023-11-25T21:19:56.810000+00:00
Original source
Assuming its autoincrement
Archived author: Honey • Posted: 2023-11-25T21:25:46.348000+00:00
Original source
You probably want to let the core know all existing IDs and let it decide the next ID for your insert query.
Archived author: Roboto • Posted: 2023-11-25T21:28:51.692000+00:00
Original source
<https://dev.mysql.com/doc/c-api/8.0/en/mysql-insert-id.html>
Not sure if it's exposed by the db abstraction layers in the core though
Archived author: Rymercyble • Posted: 2023-11-25T22:53:44.973000+00:00
Original source
i dont think so
Archived author: Rymercyble • Posted: 2023-11-25T22:54:06.410000+00:00
Original source
currently im using 2 queries i mean it works but its quite pepega
Archived author: Rymercyble • Posted: 2023-11-25T22:55:27.873000+00:00
Original source
that would be just overcomplicated solution i dont need that for this table its just for initial setup when character is logged in first time