聘我网

新概念招聘3.0

SQL语法找不出来

vote up0vote downstar
DROP TABLE IF EXISTS `kk_siteinfo_table`;
CREATE TABLE `kk_siteinfo_table` (
    `id` int(11) unsigned NOT NULL auto_increment,
    `cid` int(11) unsigned NOT NULL,
    `name` varchar(60) not null,
    `weburl` varchar(60) NOT NULL,
    `title`  varchar(100) NOT NULL,
    `keyword` varchar(100) NOT NULL,
    `desc` varchar(200) NOT NULL,
    `address` varchar(100) NOT NULL,
    `tel` varchar(12) NOT NULL,
    `display` char(2) default '0',
    `create_date` int(11) NOT NULL,
    `register_date` int(11) NOT NULL,
    `language` char(8) NOT NULL,
    PRIMARY KEY (`id`),
    KEY `cid` (`cid`),
    KEY `name` (name(10)),
    KEY `title` (title(10)),
    KEY `keyword` (keyword(10)),
    KEY `desc` (desc(10)),
    KEY `language` (`language`),
    KEY `create_date` (`create_date`)
)TYPE=MyISAM;

报错:

ERROR 1064 (42000): 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(10)),
        KEY `language` (`language`),
        KEY `create_date` (`create_date`)
)TYP' at line 20
 

2 个答复

vote up0vote down

desc在MySQL中是保留字,所以要用··括起来, 正确的语句是:

CREATE TABLE `kk_siteinfo_table` (
 `id` int(11) unsigned NOT NULL auto_increment,
 `cid` int(11) unsigned NOT NULL,
 `name` varchar(60) not null,
 `weburl` varchar(60) NOT NULL,
 `title`  varchar(100) NOT NULL,
 `keyword` varchar(100) NOT NULL,
 `desc` varchar(200) NOT NULL,
 `address` varchar(100) NOT NULL,
 `tel` varchar(12) NOT NULL,
 `display` char(2) default '0',
 `create_date` int(11) NOT NULL,
 `register_date` int(11) NOT NULL,
 `language` char(8) NOT NULL,
 PRIMARY KEY (`id`),
 KEY `cid` (`cid`),
 KEY `name` (name(10)),
 KEY `title` (title(10)),
 KEY `keyword` (keyword(10)),
 KEY `desc` (`desc`(10)),
 KEY `language` (`language`),
 KEY `create_date` (`create_date`)
)TYPE=MyISAM;
链接
vote up0vote down

谢谢站长的解答

链接
不谢,别忘了接受答案~ - Shore 2009-11-06, 08:57

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.