Insert rows into MySQL table while changing one value
- by Jonathan
Hey all-
I have a MySQL table that defines values for a specific customer type.
| CustomerType | Key Field 1 | Key Field 2 | Value |
Each customer type has 10 values associated with it (based on the other two key fields).
I am creating a new customer type (TypeB) that is exactly the same as another customer type (TypeA). I want to insert "TypeB" as the CustomerType but then just copy the values from TypeA's rows for the other three fields.
Is there an SQL insert statement to make this happen?
Somthing like:
insert into customers(customer_type, key1, key2, value) values
"TypeB" union
select key1, key2, value
from customers
where customer_type = "TypeA"
Thanks-
Jonathan