简体   繁体   English

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

[英]Query A MySQL Table & Insert Results Into Another Table

This is my code with comments.这是我的注释代码。

//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;
 }

The problem I'm facing is that the page doesn't even load when I run this code & there are no error messages.我面临的问题是当我运行此代码时页面甚至没有加载并且没有错误消息。 What is wrong with my code & how do I fix it please?我的代码有什么问题以及如何解决?

Thanks.谢谢。

Something like this...像这样的东西...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM