Insert INTO a table combining * with a column value In MySQL, I am trying to insert all values from table A to table B, but I need to change the structure of table B and a column where all the values would be 0.
Is it possible to mix and create such a query as below, or what could be the possible query for this case?!
Many thanks.
$limitid = 50;
$pr1 = &quot;INSERT INTO B SELECT * FROM A where A.id &gt; $limitid ;
//to get 
$pr1 = &quot;INSERT INTO B (*,col10) VALUES(*,0);
You can do it this way
$pr1 = &quot;INSERT INTO B SELECT *, 0 col10 FROM A where A.id &gt; $limitid&quot;

But this code is vulnerable to sql injection  so use only prepared statemenst with parameters see https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php