What I have done is added two new fields into "orders_products" that need to contain a part number and an old part number (called product_part & product_old_part respectively). Going forward, all new orders will fill in these fields, but what I can't figure out is how to fill in the fields for thousands of previous orders.
Somehow I need to tell MySQL to look at the "orders_products" table and find the 'products_id' field. Then find a match for that number in the 'products_id' field of the "products" table. When it finds a match, it needs to take the values listed for 'product_part' and 'product_old_part' from the "products" table and insert it into the corresponding fields in the "orders_products" table.
Any thoughts on how to accomplish this? Seems like it should be easy, but that I'm missing the obvious. Any help would be appreciated. Thanks
Here's what the tables kind of look like:
orders_products
Expand|Select|Wrap|Line Numbers
- --------------------------------------------------------
- orders_id| products_id| orders_tax| products_part| etc |
- --------------------------------------------------------
- 1 12 0.34 NULL ...
- 2 13 0.64 NULL ...
- 3 14 3.52 NULL ...
- 4 15 9.76 NULL ...
- ... ... ... ... ...
- --------------------------------------------------------
products
Expand|Select|Wrap|Line Numbers
- --------------------------------------------------------
- products_id | products_model | products_part | etc |
- --------------------------------------------------------
- 12 IB45 47592N24 ...
- 13 SN59 08572E84 ...
- 14 OI18 84083R09 ...
- 15 PE97 08647W38 ...
- ... ... ... ...
- --------------------------------------------------------
EDIT: There was a duplicate 12, sorry about that.