无论我做什么,我都会遇到语法错误,我无法弄明白为什么?
$sn= "INSERT INTO [Drive Errors](Serial Number) SELECT [Serial Number] FROM [Drive List] ORDER BY [Position]ASC";
odbc_exec($con,$sn);
谢谢,代码可以正常运行,但是当我插入序列号数据时,现在所有以前的数据都被删除了。有什么建议?
$sn= "INSERT INTO [Drive Errors]([Serial]) SELECT [Serial Number] FROM [Drive List] ORDER BY [Position]ASC";
odbc_exec($con,$sn);
//Selecting table(de) and row(pos) need it in brackets
$sql= "SELECT * FROM [Drive Errors] ORDER BY [Position]ASC";
$rs=odbc_exec($con,$sql);
if (!$rs)
{echo("Error");}
答案 0 :(得分:1)
您还需要围绕第一个Serial Number
使用方括号:
$sn= "INSERT INTO [Drive Errors]([Serial Number]) SELECT [Serial Number] FROM [Drive List] ORDER BY [Position]ASC";
圆括号是INSERT语句语法的一部分;方括号是用空格或有趣字符分隔列名,或者是Access SQL中的保留字。