如何将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?)
答案 0 :(得分: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 = ?"
);