mysql - SQL Query to duplicate records based on If statement -


i'm trying write sql query duplicate records depending on field in table. running mysql 5.

(i know duplicating records shows database structure bad, did not design database , not in position redo - it's shopp ecommerce database running on wordpress.)

each product particular attribute needs link same few images, product need row per image in table - database doesn't contain image, filename. (the images of clipart customer select from)

based on these records...

select * `wp_shopp_spec` name='can personalised' , content='yes' 

i want this..

for each record matches query, copy records 5134 - 5139 wp_shopp_asset change id it's unique , set cell in column 'parent' have value of 'product' table wp_shopp_spec. mean 6 new records created each record matching above query, same value in 'parent' unique ids , every other column copied original (ie. records 5134-5139)

hope that's clear enough - appreciated.

it sounds need cross join asset values want. like:

select spec.parent, asset.id uniqueid, ... from`wp_shopp_spec` spec     cross join  (                 select id                 `wp_shopp_asset`                 id between 5134 , 5139                 ) asset name='can personalised'      , content='yes' 

Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -