简体   繁体   中英

Better way to do this MySQL query?

This is what I'm doing now, how to do this without resorting to a subquery and without the php. I can just run it inside phpmyadmin directly:

   <?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!') ");
    }

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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