-3

我在 SQL 中创建了一个表,但我得到了错误......

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 ' pub_name VARCHAR, pub_city VARCHAR, country ' at line 2

CREATE TABLE  publisher(  
'pub_id'      varchar(8),  
'pub_name'        varchar(50),  
'pub_city'        varchar(25),  
'country'         varchar(25),  
'country_office'  varchar(25)  
'no_of_branch'    int(3),  
'estd'           date);  
4

3 回答 3

1

,您在“country_office”行之后忘记了一个。

顺便说一句,您应该在每个列名周围使用反引号:` 而不是简单的引号!

CREATE TABLE publisher (  
`pub_id`          varchar(8),
`pub_name`        varchar(50),
`pub_city`        varchar(25),
`country`         varchar(25),
`country_office`  varchar(25),  <-
`no_of_branch`    int(3),
`estd`            date );
于 2013-05-09T08:10:04.873 回答
0
CREATE TABLE publisher
(  
`pub_id` varchar(8),  
`pub_name` varchar(50),  
`pub_city` varchar(25),  
`country` varchar(25),  
`country_office` varchar(25),  --The problem is here, You are missing a comma
`no_of_branch` int(3),
`estd` date
); 

你也应该使用`而不是'

SQL 小提琴

感谢不幸的小提琴

于 2013-05-09T08:10:46.647 回答
0

尝试这个

CREATE TABLE  publisher(pub_id varchar(8), pub_name varchar(50),  
pub_city varchar(25), country varchar(25), country_office varchar(25) , no_of_branch  int(3), estd date);  
于 2013-05-09T08:12:23.760 回答