简体   繁体   中英

SQL ERROR - Error sql syntax

I am getting an error that I dont know how to deal with. I am running the same code without issue for another column but for this column it refuses to work.

SELECT * FROM Players WHERE Character = 'momo' // This one wont work

SELECT * FROM Players WHERE Class = 'Fighter' // this one works

Character is a VARCHAR and Class is TEXT. I have tried changing Character to TEXT and I still get the same issue. The value 'momo' exists in the table.

ERROR: Couldn't connect to server. SQLSTATE[42000]: Syntax error or access violation: 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 '= ''' at line 1

Edit: I am editing this incase someone find this and wants to know how it was fixed. User by the name of ueerdo Pointed out that I should use quotations and when I did, it worked. So I started looking into why it happened and I found out the SQL reserves Character for something else so it is something that I can't use unless it is in quotations.

最好对标识符进行分隔,以防止可能与保留字和关键字发生冲突。

SELECT * FROM `Players` WHERE `Character` = 'momo'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM