I need to fill MS access database table with a number of information about certain products. I managed to fill almost everything, but I ran into following issue:
I have a separate record for each part of the same product in a table called Parts. I also have a separate record for each product in a table called Products.
I need to take data from Parts.PartCode to Products.ListOfParts if the Parts.ProductCode and Products.ProductCode is the same, however I have two problems:
- I do not know how to make a query that will fill particular row in Products.ListOfParts with data from numerous rows in Parts.PartCode (could be anything between 1 and 10);
For some reason, even though the table Products is filled completely, except for the Products.ListOfParts column, every time I try to make an
INSERT
query, it asks me to provide value of Products.ProductCode. This is the query I tried running:INSERT INTO Products ( ListOfParts ) SELECT Parts.PartCode FROM Parts WHERE Parts.ProductCode = Products.ProductCode;
Edit (sample data from tables):
Products:
+----+---------+-------+-------------+-------------+
| Id | Name | SpId | ListOfParts | ProductCode |
+----+---------+-------+-------------+-------------+
| 1 | HWN2007 | Y2271 | | OP00P0 |
| 2 | SD39HE | 6G121 | | NE0301 |
+----+---------+-------+-------------+-------------+
Parts:
+-------+---------+-------------+-----------+
| Id | SpId | ProductCode | PartCode |
+-------+---------+-------------+-----------+
| 15321 | 5162F7 | OP00P0 | VC-192919 |
| 15322 | 5172H1 | OP00P0 | VC-888192 |
+-------+---------+-------------+-----------+
Desired result:
+----+---------+-------+----------------------+-------------+
| Id | Name | SpId | ListOfParts | ProductCode |
+----+---------+-------+----------------------+-------------+
| 1 | HWN2007 | Y2271 | VC-192919, VC-888192 | OP00P0 |
+----+---------+-------+----------------------+-------------+