select-insert

SQL Insert into table new rows foreach field in same table

为君一笑 提交于 2020-12-13 03:16:37
问题 I have a database of categories, sub-categories and products. Many sub-categories and therefore their products weren't adopted by the parent categories so I'm trying to use SQL to fix this but I'm coming across some issues. Said table has three columns; id_category, id_product, position (they are all ints) In this table every time a product is in a category, it's repeated for that id_product for each id_category of given categories. Whether that be parent or sub-category. As for an example,

SQL Insert into table new rows foreach field in same table

僤鯓⒐⒋嵵緔 提交于 2020-12-13 03:14:47
问题 I have a database of categories, sub-categories and products. Many sub-categories and therefore their products weren't adopted by the parent categories so I'm trying to use SQL to fix this but I'm coming across some issues. Said table has three columns; id_category, id_product, position (they are all ints) In this table every time a product is in a category, it's repeated for that id_product for each id_category of given categories. Whether that be parent or sub-category. As for an example,