Ofir Attia Ofir Attia - 7 months ago 8
PHP Question

Copy From One Table To Another Specific Cols And Variables

Hi,

I Want to copy from one table to another with the specific cols.

In addition i want to add to the query an external variable. for example in one table i have col1,col2,col3 and in the second table i have the same cols ( col1,col2,col2 )

but now i want to insert to the col4 a variable. it will be like : insert into col1,col2,col3,col4 select (col1,col2,col3,$VARIABLE)

$copy_cols= 'INSERT INTO A (COL1,COL2,COL3,COL4) SELECT COL1,COL2,COL3,$VAR FROM B WHERE Descriptiontable="AAA"';
mysql_cols($copy_query);


the col4 is not can be found in table B , so i want to insert to this col some variable.. for example : the variable can be a constant number.

ste ste
Answer
$copy_cols = 'INSERT INTO A (COL1,COL2,COL3,COL4) 
              SELECT COL1,COL2,COL3,'FOO' AS COL4 
              FROM B WHERE Descriptiontable="AAA"';
mysql_cols($copy_query);
Comments