I am creating an API in PHP and I am stuck at a point where I need same data of one table into another.
In table one, the order ID is created by auto increment. I want to copy its order ID into the 2nd table order ID:
So a customer can add multiple items in same order:
I'm not sure if I understand your problem correctly. Are you asking how you can move data between two tables? Because if that's so, it's quite simple to do:
Let's suppose you want to move a record from table foo
to table bar
, you can use the query:
INSERT INTO `bar` (SELECT * FROM `foo` WHERE id = $some_id)
Where $some_id
is the ID of the record you want to move.
But again, your question wasn't very clear, so apologies if this isn't what you were trying to do.