查询 MySQL 表并将结果插入另一个表

时间:2020-12-28 17:19:26

标签: php mysql

这是我的带有注释的代码。

//Query the good_keywords table & pick one result at random
$result4 = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * from `good_keywords` ORDER BY RAND() LIMIT 1,1");

while($rows4=mysqli_fetch_array($result4)){ 
$tagline = $rows4['keyword'];
}
if (mysqli_num_rows($result4) > 0) {
/*Insert the one result obtained from the earlier query into `tran_term_taxonomy`.`description` provided that `tran_term_taxonomy`.`description` is empty & `tran_term_taxonomy`.`taxonomy` is 'post_tag'*/
$result2 = mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `tran_term_taxonomy` SET `description` = '{$tagline}' WHERE `tran_term_taxonomy`.`taxonomy` = 'post_tag' AND `tran_term_taxonomy`.`description` = "" LIMIT 1");

echo $tagline;
 }

我面临的问题是,当我运行此代码时页面甚至没有加载,并且没有错误消息。我的代码有什么问题,我该如何解决?

谢谢。

1 个答案:

答案 0 :(得分:-1)

这样的东西...

UPDATE tran_term_taxonomy x
 CROSS
  JOIN good_keywords y
   SET x.description = y.keyword
 WHERE x.taxonomy = 'post_tag'  
   AND x.description = "" 
 ORDER 
    BY RAND() LIMIT 1,1