[英]SQL INTO giving error as INTO table - undefined
I am trying to copy 1 table selected columns INTO 2nd table selected columns, using this: 我正在尝试使用以下方法将1个表选择的列复制到INTO第2个表选择的列中:
$sql = "SELECT (p.col1, p.col2)
INTO tblColors(b1,b2)
FROM tblPuppies as p
WHERE p.col3=1
";
But its giving me error : Undefined variable tblColors. 但是它给我错误:未定义的变量tblColors。 Strange to me.
对我来说很奇怪 Any guesses plz, where m going wrong ??
任何猜测,请问哪里错了? Thanks tons in Advance.
提前感谢吨。
Just use 只需使用
INSERT INTO tblColors (b1, b2)
SELECT col1, col2 FROM tblPuppies WHERE b3 = 1
Try this 尝试这个
INSERT INTO destination_table (
Field_1,
Field_2,
Field_3)
SELECT Field_1,
Field_2,
Field_3
FROM source_table;
You are using the incorrect SQL for doing this. 您正在使用不正确的SQL来执行此操作。 The syntax you used works for T-SQL (or MS-SQL).
您使用的语法适用于T-SQL(或MS-SQL)。 But you are working on MySQL which has different syntax.
但是您正在使用语法不同的MySQL。 You have update the statement as follows:
您已更新语句,如下所示:
$sql = "INSERT INTO tblColors (b1, b2)
SELECT p.col1, p.col2 FROM tblPuppies AS p WHERE b3 = 1";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.