0

I have two table:

customer:

enter image description here

and

employee:

enter image description here

How to insert multiple table in one query?

$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 of customer is auto_increment and saleorderId of saleorder is auto_increment.

If you can help, please explain the syntax.

peterh
  • 1
  • 15
  • 76
  • 99

1 Answers1

0

Use two separate insert queries in transactional block to make your oparation atomic, faster and safer (avoid inconsistency).

Przemysław Michalski
  • 9,307
  • 7
  • 30
  • 37