B
B
Bravis20182018-04-03 15:30:03
SQL
Bravis2018, 2018-04-03 15:30:03

How to add data to database?

There is a database from four tables. The order_processing table contains the orders being processed. The order ID is generated automatically using an increment. Order positions are added to the order_position table. How to correctly add information to two tables at once, without knowing under what number the order was created?

insert into order_processing(idUser) values (2)
insert into order_position(idOrder,idProduct,amount) values(1,2,13)

2ABsIZe7nyQ.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex McArrow, 2018-04-03
@Bravis2018

If MySQL

INSERT .... ;
SET @ID = LAST_INSERT_ID() ;
INSERT ... VALUES (@ID, ...) ;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question