MYSQL多表关联插入数据有关问题,请高手帮忙,死了…

WBOY
Release: 2016-06-13 13:19:26
Original
1188 people have browsed it

MYSQL多表关联插入数据问题,请高手帮忙,急死了……
我在表A中插入一条数据,其中的ID字段是自动增长的,然后我用mysql_insert_id();取得刚刚插入的这条数据的ID,然后用FOR循环向表B中插入几条数据,表B的ID是刚才用mysql_insert_id();获取到的,程序刚开始公司内部测试的时候就出现了,员工甲的插入B表的数据的ID怎么变成了员工已的ID了,就混乱了,请高手帮忙出个主意,这种问题要怎么解决,才能A表的ID和B表的ID是一样的,谢谢……

------解决方案--------------------
并发的时候可能会出现这种问题,请利用transaction,如果不支持transaction,就用锁

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!