0

如何将 mysql insert 和 select 语句组合成准备好的语句?当我点击“复制”按钮时,这部分代码会帮助我将信息复制到数据库中吗?

谢谢。

INSERT INTO assignment_speeches_copy (id, subject, body, tags, image)
SELECT * FROM assignment_speeches
WHERE id = $id";

$stmt = $mysqli->prepare("INSERT INTO assignment_speeches_copy VALUES (?,?,?,?,?)"); (how do I continue?)
4

1 回答 1

0

你不必结合任何东西。INSERT ... SELECT是一个简单的陈述......

$stmt = $mysqli->prepare(
    "INSERT INTO assignment_speeches_copy (id, subject, body, tags, image) 
        SELECT (id, subject, body, tags, image) 
           FROM assignment_speeches 
           WHERE id = ?"
    );
于 2013-08-04T18:45:09.910 回答