如何使用另一个 table 的关系更新列值

How to update column values with relation of another table

如何使用 php 从 main_cat_list.id 动态添加 sub_cat_list.child_id。下面是我的 parent 和 child table

的 2 张图片

如何使用 php

相对于 sub_cat_list=rel_main_cat 添加值到 sub_cat_list.child_id

为什么要使用 php? 一个查询是可能的(如果我正确理解你的问题)。

UPDATE sub_cat_list sub
 INNER JOIN main_cat_list main ON main.main_cat_name = sub.rel_main_cat
   SET child_id = main.id