I’m trying to learn more with SQL and I am trying to INSERT a List of Numbers linked with 1 ID (row).
Now I figured out how to use List in SELECT, basics like
SELECT * FROM products WHERE catalog_number IN ("CAT1", "CAT2", "CAT3");
and I am trying to do a similar thing but with INSERT
Something like this but this won’t work, sadly.
INSERT INTO link_products ('main_product_id', 'linked_product_id') VALUES (124, IN(1,2,3,4,))
Basicly I am trying to do like php foreach
command fully in SQL (in phpmyadmin
) and I am not even sure if this is possible.
The result should be (in database):
id | main_product_id | linked_product_id
1 124 1
2 124 2
3 124 3
4 124 4
3
Answers
Just insert the data like:
I suppose you’ll need something like