问题 2011-12-17 00:18:38 点击:42540
[数据库] mysql中两张表关联如何实现同时插入数据
有order表,里面有字段order_id,是自增的,还有order_message表,里面有order_id字段与order表order_id相同。向order表插入一条数据生成order_id后,再将order_id的值插入到order_massage表、
有order表,里面有字段order_id,是自增的,还有order_message表,里面有order_id字段与order表order_id相同。向order表插入一条数据生成order_id后,再将order_id的值插入到order_massage表、
推荐答案 2011-12-17 00:18:38
在insert语句后写";SELECT @@IDENTITY"、
然后用"ExecuteScalar"方法查询单条记录即可、
个人理解、
- 1楼 Malinda说: 2016-09-09 14:43:12
-
If you wrote an article about life we'd all reach entnlhgeiment.
- 2楼 chocopie说: 2018-12-21 11:05:57
-
cKfgI6 This very blog is no doubt educating and also amusing. I have picked many interesting stuff out of this source. I ad love to go back again and again. Thanks a lot!
- 3楼 Kaylamog说: 2019-03-27 10:32:48
-
Hello, did you receive my offer? from2325214cv
- 4楼 FerneFah说: 2020-08-03 06:36:41
-
Hello my friend. Our employees wrote to you yesterday maybe... Can I offer paid advertising on your site?
发表评论