鉴于此表结构,
categories{id}
product_models{id, category_id}
products{product_model_id, category_id}
已经填充了,但是使用product_models.category_id,products.category_id并且products.product_model_id全部设置为NULL,我需要一个查询来“连接”它们,执行以下操作:
- 将 all , 设置为表
product_models.category_id中的随机值categories - 将 all , 设置为表
products.product_model_id中的随机值product_models - 将 each 设置
products.category_id为新分配product_models记录的 category_id 的值。
可以在单个查询中完成吗?