开发者

adding a user and selecting that user id from the DB in 1 query

开发者 https://www.devze.com 2023-02-28 09:31 出处:网络
What i would like to do is add a user to the DB. I have an id that auto-increments each time a user is added, but the problem is that i would like to get the id back from the user i just added and i w

What i would like to do is add a user to the DB. I have an id that auto-increments each time a user is added, but the problem is that i would like to get the id back from the user i just added and i would like to do it in 1 query. Anyone that ca开发者_高级运维n help me?


In PHP you do with mysql_insert_id()

mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
0

精彩评论

暂无评论...
验证码 换一张
取 消