Reputation: 1192
I am using this query to retrieve auto incremented key value of "invoiceNo"
"SELECT AUTO_INCREMENT FROM information_schema.TABLES
where TABLE_SCHEMA='DB_NAME' and TABLE_NAME='invoice';"
and using that value as Foreign Key and inserting into invoice_sub table
I use following query to insert into invoice and invoice_sub tables
insert into invoice(netAmount)
insert into invoice_sub(PK, itemDescr, itemPrice)<br>
PK= AUTO_INCREMENT value
What if two or more users inserting at same time
Upvotes: 1
Views: 121
Reputation: 204894
Don't do that like this!
invoice
. The ID will be calculated automatically. invoice_sub
Upvotes: 3