作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个表:
客户:
和
员工:
如何在一个查询中插入多个表?
$sql="INSERT INTO saleorder ('employeeId','customerId','totalAmount','saleDate') values('$employeeId','$customerId','$totalAmount','$saleDate')";
$sql="INSERT INTO customer ('customerCode','customerName','gender','email') values('$customerCode','$customerName','$gender','$email')";
客户的_customerId是auto_increment,saleorder的saleorderId是auto_increment。
如果您能提供帮助,请解释一下语法。
最佳答案
在事务 block 中使用两个单独的插入查询,使您的操作原子化、更快、更安全(避免不一致)。
关于mysql - 如何在mysql中插入多表查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37521407/
我是一名优秀的程序员,十分优秀!