Skip to content
Advertisement

How to transfer several rows from one table to other table (SQL)

I have two tables TableA and TableB with colums id, login, pass. Also I have a php array: $array = [1,3,5]. How can I transfer rows from TableA to TableB where id equal each value of my array? id is autoincremented and must be unique. In my head it looks like this :

JavaScript

But it does not work

Is there any chances to do it in cycle using WHILE?

Advertisement

Answer

You can use a statement such as this:

JavaScript

Although: You should be using prepared statements and parameters for this, this answer is just meant to show the syntax.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement