0

When using the query below I'm inserting product_id and I also want to set field category_id = 4 for all inserted product_ids. Here's my code to insert products.

INSERT INTO lc_products_to_categories
( product_id)
SELECT product_id
FROM lc_products_info
where name like '%awesome product%'

How to update category_id with single query?

1
  • just select the constant like this NSERT INTO lc_products_to_categories ( product_id,category_id) product_id, 4 FROM lc_products_info where name like '%awesome product%' Commented Jul 6, 2017 at 9:51

1 Answer 1

0
INSERT INTO lc_products_to_categories
( product_id, category_id)
SELECT product_id, 4
FROM lc_products_info
where name like '%awesome product%'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.