views:

21

answers:

1

I want to run an

INSERT ... SELECT

Manual

query to insert 1 selected column column with the exact amount of 2 rows from one table to another.

Along with this I would like to insert an additional column of static values.

Example

| selected column | static val |
     Variable          4              
     Variable          9

static values 4 & 9 are specified in my php script. Can I do this in 1 mysql query, not using php to store temporary data?

+2  A: 

You can use UNION ALL to select from the source table twice like this:

insert into new_table
   select column, 4 from old_table
union all
   select column, 9 from old_table;
ar