使用UniServerZ的MySQL语法错误

时间:2014-11-06 00:10:34

标签: mysql sql syntax

我编写了一些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 />");
}

1 个答案:

答案 0 :(得分:0)

请在此行重命名desc

desc varchar(25) NOT NULL

其他东西,因为它是MySQL中的reserverd word

some_stuff varchar(25) NOT NULL