【发布时间】:2014-11-06 00:10:34
【问题描述】:
我编写了一些 SQL 并运行它以查找几乎所有表中的错误。这是我得到的表格错误:
Error creating table 'Region': You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near
'desc varchar(25) NOT NULL, PRIMARY KEY(regID))' at line 1
我的代码:
mysql_select_db($dbName, $dbConnection);
$sql = "CREATE TABLE ".$dbTableRegion." (regID int(4) auto_increment NOT NULL, desc varchar(25) NOT NULL, PRIMARY KEY(regID))";
if(mysql_query($sql, $dbConnection))
{
echo("Table '".$dbTableRegion."' created<br />");
}
else
{
echo("Error creating table '".$dbTableRegion."': ".mysql_error()."<br />");
}
【问题讨论】:
-
你可以使用`来括起desc。它是mysql中的系统字