Hvis jeg forstår det rigtigt, skal du bare CROSS JOIN
. Prøv
INSERT INTO bullets (product_code, bullet_text)
SELECT m.product_code, b.bullet_text
FROM bullets b CROSS JOIN master m
WHERE b.product_code = 10001
AND m.product_group = 3
AND m.product_code <> 10001;
Her er SQLFiddle demo.
Nu kan du pakke det ind i en lagret procedure, hvis du gik til
CREATE PROCEDURE copy_bullets_test (IN product_code_from INT, IN product_group_to INT)
INSERT INTO bullets (product_code, bullet_text)
SELECT m.product_code, b.bullet_text
FROM bullets b CROSS JOIN master m
WHERE b.product_code = product_code_from
AND m.product_group = product_group_to
AND m.product_code <> product_code_from;
Og brug det
CALL copy_bullets_test(10001, 3);
Her er SQLFiddle demo for den sag.