2017-04-19 161 views
1

您好,感謝您閱讀我的問題!我收到這段代碼的語法錯誤,但我無法弄清楚什麼是錯的。任何見解都非常感謝。MySQL的語法錯誤,無法弄清楚什麼是錯

mysql> create table match (
-> event_id int not null, 
-> player1_id int, 
-> player2_id int, 
-> player1_score int, 
-> player2_score int, 
-> winner_id int, 
-> foreign key (event_id) references event(id) 
->); 
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 'match (
event_id int not null, 
player1_id int, 
player2_id int, 
player1_score int' at line 1 

我找不到任何缺少的逗號,並且事件表肯定存在一個id列。任何想法我失蹤?謝謝!

+0

匹配是一個保留字 - 表名不好選 – Strawberry

回答

2

匹配是reserved word。用反引號括起來:

create table `match` ... 
+0

謝謝!我一直在搜索,因爲我認爲可能是這樣,但無法找到它。你是一個救星! – user4595737

+0

非常歡迎。 – bernie

+1

現在值得檢查關鍵字列表,然後提供關於不命名錶和列的內容。當它是你想使用的術語時,它可能會令人討厭,但它比煩惱要少得多,因爲每次引用它時都需要像這樣轉義。 – tadman

相關問題