私がやろうとしているのは、いくつかの列を他のテーブルにコピーすることです。obj_id
UPDATE obj_object
INNER JOIN obj_extract as address ON (obj_object.id = address.obj_id AND address.category_id = 1)
INNER JOIN obj_extract as city ON (obj_object.id = city.obj_id AND city.category_id = 2)
INNER JOIN obj_extract as country ON (obj_object.id = country.obj_id AND country.category_id = 3)
INNER JOIN obj_extract as phone ON (obj_object.id = phone.obj_id AND phone.category_id = 4)
SET obj_object.address = address.info,
obj_object.city = city.info,
obj_object.country = country.info,
obj_object.phone = phone.info
しかし、いくつかのobj_extract
行は同じです。同じものを含むレコードに同じ行が複数あるcategory_id
かどうかを数える必要があります。そうであれば、これらのエントリを作成してテーブルの列にコピーする必要があります。表の例:obj_id
category_id
concat
obj_object
+----+--------------+---------+---------+
| ID | category_id | info | obj_id |
+----+--------------+---------+---------+
| 1 | 1 | test | 2 |
+----+--------------+---------+---------+
| 2 | 1 | test1 | 2 |
+----+--------------+---------+---------+
| 3 | 2 | test2 | 2 |
+----+--------------+---------+---------+
私は次のようになる必要があります:
obj_object.address = 'test - test1', // // value from address.info
obj_object.city = 'test2', // value from city.info