[英]How can i resolve this error - ERROR 1064 (42000): You have an error in your SQL syntax
[英]ERROR 1064 (42000): You have an error in your SQL syntax; I can't find that I did wrong
mysql> DESC transaction;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(100) | NO | | NULL | |
| from | int(11) | NO | | NULL | |
| to | int(11) | NO | | NULL | |
| cost | int(11) | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)
mysql> INSERT INTO transaction (title, from, to, cost) VALUES ('Ham', 1, 4, 9000);
ERROR 1064 (42000): 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 'from, to, cost) VA
LUES ('Ham', 1, 4, 9000)' at line 1
我試圖將數據插入“交易”表。 我認為查詢很好,但是卻說錯誤。 我怎么了 請幫我!
采用:
select "from", cost from...
代替:
select from, cost from...
將Tsql插入到:
INSERT INTO `transaction` (`title`, `from`, `to`, `cost`) VALUES ('Ham', 1, 4, 9000);
在MySQL中,某些詞(例如SELECT,INSERT,FROM等)是保留詞。 由於它們具有特殊含義,因此每當您將它們用作表名,列名或其他類型的標識符時,MySQL都會將其視為語法錯誤-除非您用反引號將標識符引起來。
有關更多詳細信息,請參見https://dev.mysql.com/doc/refman/5.7/en/keywords.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.