处理负数时出现mysql语法错误

时间:2022-05-10 15:38:18

The MySQL Syntax Used

使用的MySQL语法

INSERT INTO friend_locations 
(user_id, lat, long) 
VALUES 
('82441', '28.665899', '-81.359756') 

The MySQL Error Returned 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 'long) VALUES ('82441', '28.665899', '-81.359756')' at line 1

返回MySQL错误您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以便在第1行使用“long”VALUES('82441',''286658',' - 81.359756')附近的正确语法

I don't understand this

我不明白这一点

UPDATE

the syntax coloring on this site made long stand out, that must be my issue

这个网站上的语法着色很长,这一定是我的问题

2 个解决方案

#1


You need to change

你需要改变

(user_id, lat, long)

to

(user_id, lat, `long`)

since the word long is a reserved word.

因为long这个词是保留字。

I try (but don't always remember) to just wrap all of my field names in backticks so I don't have to worry about that sort of thing.

我尝试(但不要总是记住)只是将我的所有字段名称包含在反引号中,这样我就不用担心那种事了。

#2


If you quote your field-names with backticks, it ensures that MySQL doesn't confuse them with keywords:

如果你用反引号引用你的字段名称,它可以确保MySQL不会将它们与关键字混淆:

INSERT INTO foo (`varchar`, `long`, bar) VALUES('zing', 2212323.02, 'yo mama!');

See MySQL docs on identifiers:

请参阅有关标识符的MySQL文档:

http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

#1


You need to change

你需要改变

(user_id, lat, long)

to

(user_id, lat, `long`)

since the word long is a reserved word.

因为long这个词是保留字。

I try (but don't always remember) to just wrap all of my field names in backticks so I don't have to worry about that sort of thing.

我尝试(但不要总是记住)只是将我的所有字段名称包含在反引号中,这样我就不用担心那种事了。

#2


If you quote your field-names with backticks, it ensures that MySQL doesn't confuse them with keywords:

如果你用反引号引用你的字段名称,它可以确保MySQL不会将它们与关键字混淆:

INSERT INTO foo (`varchar`, `long`, bar) VALUES('zing', 2212323.02, 'yo mama!');

See MySQL docs on identifiers:

请参阅有关标识符的MySQL文档:

http://dev.mysql.com/doc/refman/5.0/en/identifiers.html