2012-05-10 36 views
1

這就是我現在正在做的,如何做到這一點,而不訴諸於一個子查詢和沒有PHP。我可以直接在phpmyadmin中運行它:更好的方式來做這個MySQL查詢?

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

    ?> 

回答

3
INSERT INTO node_teaser(node_id, content) 
SELECT node_id, 'This is the teaser!' FROM embeds; 
相關問題