mysql, insert with select sub query
mysql
Solution
try this:
INSERT INTO product_categories (category_id, product_id)
SELECT 19 AS category_id, product_id
FROM product_categories
WHERE category_id =5;
Problem
I have lots of products in a `product_category` table with a `category_id` of 5. I have added a new `category_id` of 19. How do I add all products in category 5 to category 19 as well? I am trying to do something like this: ``` insert into product_categories( category_id, product_id ) select 19, (select product_id from product_categories where category_id = 5) ``` but I am getting a `sub query returns more than 1 row` error.