mysql select static list
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 开发者_JAVA百科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?
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;
精彩评论