使用 MySQL,我尝试在数据库中创建一个表,然后插入,但得到一个“语法”:错误

发布于 2024-10-12 01:58:28 字数 1269 浏览 10 评论 0原文

这是创建表:

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_' 附近使用的正确语法

Here's the create table:

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));

and here's the insert:

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');`

What I don't get is why I'm getting:

#1064 - 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 ''firm_name','firm_url','firm_address','firm_city','firm_state','firm_zip','firm_' at line 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温柔一刀 2024-10-19 01:58:28

列名应该不加引号,或者在 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');`

Column names should be unquoted, or backtick quoted in 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');`
乖乖公主 2024-10-19 01:58:28

您不应该引用您的属性名称。例如,

insert into lawyer_info (firm_name,firm_url, etc.)

You shouldn't quote your attribute names. e.g.,

insert into lawyer_info (firm_name,firm_url, etc.)
做个少女永远怀春 2024-10-19 01:58:28

你不应该使用普通的引号,而应该使用反引号作为你的列名称......它应该是

Insert into lawyer_info (`firm_name`,`firm_url`,`firm_address`,`firm_city`,`firm_state`,`firm_zip`,`firm_phone`)

You shouldn't use normal quotes, but backticks for your colum names... it should be

Insert into lawyer_info (`firm_name`,`firm_url`,`firm_address`,`firm_city`,`firm_state`,`firm_zip`,`firm_phone`)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文