Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
888 views
in Technique[技术] by (71.8m points)

mysql - Error Code: 1064 - You have an error in your SQL syntax

I have a very strange problem with this code:

Update creature_template SET health_min=(health_min * 0.03) where entry in (select entry from creature where rank ='1');
Update creature_template SET health_max=(health_max * 0.03) where entry in (select entry from creature where rank ='1');

Error occured at:2021-01-07 13:27:46 Line no.:1 Error Code: 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 '='1')' at line 1

I use mysql 8.x and I am a beginner. in mysql 5.x this problem does not exist. Anyone if can help i would be grateful.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

rank is a reserved word in MySQL since version 8.0.2. You need to escape it with backticks

... where `rank` = '1' ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...