这是创建表:
create table lawyer_info
(firm_name varchar(100),
firm_url varchar(100),
firm_address varchar(100),
firm_city varchar(100),
firm_state varchar(100),
firm_zip int(5),
firm_phone varchar(12));
这是插入内容:
insert into lawyer_info ('firm_name','firm_url','firm_address','firm_city','firm_state','firm_zip','firm_phone')
values('Leona Beane','http://www.lawyerlbeane.com/','11 Park Place, Suite 1100','New York','NY','10007','212-608-0919'),
values('Morton S. Minsley','http://www.msmlawfirm.com/','101 Lafayette Street, 10th Floor ','New York','NY','10013','212-346-0849'),
values('Steven K. Schwartz, P.A.,','http://www.stevenkschwartzpa.com/','20801 Biscayne Blvd','Aventura','FL','33180','305-936-8844'),
values('Robert H. Feldman','http://www.lawyers.com/rhfeldman/','3550 North Central Avenue, Suite 1500','Phoenix','AZ','85012','602-265-1074'),
values('Joseph M. Udall, PLC','http://www.udallattorneys.com/','18 East University, Drive,Suite 201','Mesa','AZ','85201','480-222-0398');`
我没有得到的是我得到的原因:
#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以便在第1行''firm_name','firm_url','firm_address','firm_city','firm_state','firm_zip','firm_'附近使用正确的语法
答案 0 :(得分:1)
列名应该不加引号,或者在MySQL中引用反引号:
insert into lawyer_info (firm_name, firm_url, firm_address, firm_city,firm_state, firm_zip, firm_phone)
values('Leona Beane','http://www.lawyerlbeane.com/','11 Park Place, Suite 1100','New York','NY','10007','212-608-0919'),
values('Morton S. Minsley','http://www.msmlawfirm.com/','101 Lafayette Street, 10th Floor ','New York','NY','10013','212-346-0849'),
values('Steven K. Schwartz, P.A.,','http://www.stevenkschwartzpa.com/','20801 Biscayne Blvd','Aventura','FL','33180','305-936-8844'),
values('Robert H. Feldman','http://www.lawyers.com/rhfeldman/','3550 North Central Avenue, Suite 1500','Phoenix','AZ','85012','602-265-1074'),
values('Joseph M. Udall, PLC','http://www.udallattorneys.com/','18 East University, Drive,Suite 201','Mesa','AZ','85201','480-222-0398');`
答案 1 :(得分:0)
您不应引用属性名称。例如,
insert into lawyer_info (firm_name,firm_url, etc.)
答案 2 :(得分:0)
你不应该使用普通引号,而是使用列名的反引号......它应该是
Insert into lawyer_info (`firm_name`,`firm_url`,`firm_address`,`firm_city`,`firm_state`,`firm_zip`,`firm_phone`)