更好的方法来做这个MySQL查询?

时间:2012-05-10 22:04:31

标签: mysql

这就是我现在正在做的事情,如何在不借助子查询和没有php的情况下做到这一点。我可以直接在phpmyadmin中运行它:

   <?php

    $query = mysql_query(" SELECT node_id FROM embeds ");
    while($row = mysql_fetch_assoc($query)) {
        $node_id = $row['node_id'];
        mysql_query(" INSERT INTO node_teaser(node_id, content) VALUES('$node_id', 'This is the teaser!') ");
    }

    ?>

1 个答案:

答案 0 :(得分:3)

INSERT INTO node_teaser(node_id, content)
SELECT node_id, 'This is the teaser!' FROM embeds;