Given this tables structure,
categories{id}
product_models{id, category_id}
products{product_model_id, category_id}
Which is already populated, but with product_models.category_id, products.category_id and products.product_model_id all set to NULL, I need a single query that will "connect" them all, doing the follow:
- set all
product_models.category_id, to a random value from thecategoriestable - set all
products.product_model_id, to a random value fromproduct_modelstable - set each
products.category_id, to the value of the category_id of the newly assignedproduct_modelsrecord.
Can it be done in a SINGLE query?