2011-01-13 41 views
-3

錯誤信息:對不起,是一個痛苦,但在MySQL另一個1064錯誤5.1.36

1064 - 你在你的SQL語法錯誤;查看與您的MySQL服務器版本相對應的手冊,以便在'values('name','url','address','city','state','zip','phone')附近使用正確的語法, ( '名' 在行3

創建表, '網址':

create table lawyer_info 
(firm_name varchar(100) not null, 
firm_url varchar(100) not null, 
firm_address varchar(100) not null, 
firm_city varchar(100) not null, 
firm_state varchar(100) not null, 
firm_zip varchar(12) not null, 
firm_phone varchar(15) not null); 

數據:

insert into lawyer_info firm_name,firm_url,firm_address,firm_city,firm_state,firm_zip,firm_phone) 
values('name','url','address','city','state','zip','phone'), 
values('name','url','address','city','state','zip','phone'), 
values('name','url','address','city','state','zip','phone'), 
values('name','url','address','city','state','zip','phone'), 
values('name','url','address','city','state','zip','phone'), 
values('name','url','address','city','state','zip','phone'), 
values('name','url','address','city','state','zip','phone'); 
+11

學會閱讀您的錯誤,至少。也許那麼你不必擔心回來發佈這麼多問題,因爲通過自己修復它們,你會少做。 – BoltClock 2011-01-13 21:42:55

+2

另外,三個「太本地化」的選票?爲什麼?我得到了集體的挫敗感,OP沒有做出任何明顯的努力去做任何有關錯誤的事情,但我不記得「太本地化」與「自己修復」是同義詞。 – BoltClock 2011-01-13 21:47:45

+0

我是。安家。 – Adam 2011-01-13 21:55:24

回答

8

MySQL的批量插入語法不需要VALUES每次:

INSERT INTO lawyer_info 
    (firm_name,firm_url,firm_address,firm_city,firm_state,firm_zip,firm_phone) 
VALUES ('name','url','address','city','state','zip','phone'), 
     ('name','url','address','city','state','zip','phone'), 
     ('name','url','address','city','state','zip','phone'), 
     ('name','url','address','city','state','zip','phone'), 
     ('name','url','address','city','state','zip','phone'), 
     ('name','url','address','city','state','zip','phone'), 
     ('name','url','address','city','state','zip','phone'); 
4

您忘記了將列列表包含進去(並且如前所述刪除了不必要的值關鍵字。 試試這個:

insert into lawyer_info (firm_name,firm_url,firm_address,firm_city,firm_state,firm_zip,firm_phone) 
values('name','url','address','city','state','zip','phone'), 
('name','url','address','city','state','zip','phone'), 
('name','url','address','city','state','zip','phone'), 
('name','url','address','city','state','zip','phone'), 
('name','url','address','city','state','zip','phone'), 
('name','url','address','city','state','zip','phone'), 
('name','url','address','city','state','zip','phone'); 
0

你不需要命名列。只是:

insert into lawyer_info 
values('name','url','address','city','state','zip','phone'), 
     ('name','url','address','city','state','zip','phone');