简体   繁体   English

刚刚提交的mysql id字段

[英]mysql id field just submitted

Ok, I find myself doing this often. 好的,我发现自己经常这样做。 I'll attach ids to my tables and I'll "link" the tables together. 我将id附加到表中,然后将表“链接”在一起。 Just a simple example, a team roster might have categories. 仅举一个简单的例子,团队花名册可能包含类别。 Each category has an id. 每个类别都有一个ID。 When I add players into the roster, I'll assign them a category id as well to signify that they are part of that category. 当我将球员添加到名册中时,我还将为其分配一个类别ID,以表示他们属于该类别。

My question is, for this example, say I'm creating a category and a player at the same. 对于这个示例,我的问题是说我要同时创建一个类别和一个播放器。 I submit the category but now I have to get the category id to assign it to the player table row. 我提交了类别,但是现在我必须获取类别ID才能将其分配给玩家表行。 Any suggestions on how to do this efficiently? 关于如何有效执行此操作的任何建议? Currently I would query the database again, and search for specific data related to the category, which doesn't seem very effective. 目前,我将再次查询数据库,并搜索与类别相关的特定数据,这似乎不太有效。

Note also, the id's Im using are generated by mysql. 还要注意,id的Im使用是由mysql生成的。

Any suggestions would be helpful! 任何的意见都将会有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM