29 Jul 2010

INSERT rows with SELECT & mixed data

To extract values from one table, to update another where you also need
to supplement the data - in this case
(`module_type_id`,`module_id`,`zone_id`,`position`) are static
(12,42,12,1) - include the supplementary values in the SELECT statement:

INSERT page_items 
(`node_descriptor_id`,`module_type_id`,`module_id`,`zone_id`,`position`)
SELECT id ,12,42,12,1 FROM node_descriptors

No comments:

Post a Comment