0

这是我的代码

 echo    '<input type="submit" name="submit">';

我正在使用此查询从另一个表中获取数据

if($_POST['submit'])
 {
    $sql = mysql_query('SELECT q.username, q.firstanme,q.lastname FROM quizgroup q');
    foreach($sql as $s)
     {
        $username = $s->username;
        $firstname = $s->firstname;
        $lastname = $s->lastname;
        $sql = mysql_query('INSERT INTO user(username,firstname,lastname) VALUES('.$username.','.$first.','.$last.')');
     }
 }
4

1 回答 1

2

尝试这个

insert into user (SELECT username, firstanme, lastname FROM quizgroup)

此语句将数据从 quizgroup 复制到用户表

复制数据时不要使用“values”关键字

看这个

http://dev.mysql.com/doc/refman/5.0/en/insert-select.html

于 2012-07-18T10:29:41.503 回答