How to make a relational update between a data table and a data table?

SQL

$rs = $do->query(
    "SELECT
      t.name as name,
      tr.object_id as object_id
    FROM wp_terms as t
    JOIN wp_term_relationships as tr ON tr.term_taxonomy_id = t.term_id
    JOIN blog as b ON b.url = tr.object_id "
  );

UPDATE

while ($r = mysqli_fetch_array($rs)){

  $key = "";
  $key .= $r["name"];

  $do->query(
    "UPDATE `blog` SET
    `tags` = "{$key}"
    WHERE url = "{$r["object_id"]}" "
  );

}

according to t and tr , use tr.object_id to t to find the corresponding t.name

.

Database structure:
object_id / name
clipboard.png

The purpose of

is that I update to the tags field of the number table blog and use , separation.
and tr.object_id also means b.url

blog as b
url / tags

for example, in this blog, post of 13421, I want to add all his name to b.tags , using , to separate

.

but the problem that arises now is that forever is the last one to be updated into b.tags!
suppose this blog finds a b.tags, , the only time you enter b.tags is e,
what"s going on?

Jul.29,2021

your while , each time you execute $key , you leave $r ['name'] connected, and each while has UPDATE .

you need to bring $key='' out of the loop.

I don't know what your plan is. According to your code, if you are a code, a code, , , , , , , and , it will be updated five times as , , and then update five times as , , , , , , < , . If you only want to update once, your UPDATE should also mention out-of-loop

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e83be7-c82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e83be7-c82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?