0

I am trying to execute a query on MySQL server but it is throwing below errors. It was working fine on MySQL server 5.1 but now I am using 8.0

Query

SELECT group1s.group_id, group1s.customer_id
 FROM icm_b_instance_group1s as group1s inner join icm_b_instance_groups 
as groups on group1s.group_id = groups.group_id
 where group1s.is_active = 'Y' and groups.is_active = 'Y';

[Code: 1064, SQL State: 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 'groups on group1s.group_id = groups.group_id' at line 2

1 Answer 1

1

From MySQL 8.0 Keywords and Reserved Words

GROUPS (R); added in 8.0.2 (reserved)

So groups which you use as an alias is a reserved word and cannot be used in versions 8.0.2+

Sign up to request clarification or add additional context in comments.

3 Comments

It can be used, if you use backticks around it. Although it is better to rename alias to something else.
Reserved words should not be used in any case to avoid such errors and confusion. The problem is with the new reserved words that each new version may add. So renaming all old uses is the best option.
Thank you very much @forpas

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.