关于 mysql 别名有什么具体规定吗?

Is there any specific rules concerning about mysql alias?

最近,我正在按照这个特定指南学习 MySQL。 https://www.mysqltutorial.org/mysql-join/

已按照教程中的指示设置数据库和表。而运行下面的代码,会导致语法错误

SELECT 
    m.member_id, 
    m.name member, 
    c.committee_id, 
    c.name committee
FROM
    members m
INNER JOIN committees c 
 ON c.name = m.name;

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 ', 
    c.committee_id, 
    c.name committee
FROM
    members m
INNER JOIN commi' at line 3

通过一些实验,可以通过将别名成员更改为其他内容或在其周围添加引号来修复此语法错误。但是,我不清楚这些解决方案如何以及为何起作用。 PS: 我使用的MySQL版本是Ver 8.0.19.

member 在某些特定的 MySQL 版本上是 a reserved word:它在版本 8.0.17 中被保留,然后似乎 MySQL 设计者改变了主意并逆转了在版本 8.0.19.

因此您需要更改别名(我会推荐),或者用反引号将其括起来:这会将其变成带引号的标识符,不会与保留字冲突,如 explained in the documentation:

An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it.

并且,进一步:

The identifier quote character is the backtick (`)

member是一个reserved word,所以必须用单引号把mmmber封装起来

SELECT 
    m.member_id, 
    m.name 'member', 
    c.committee_id, 
    c.name committee
FROM
    members m
INNER JOIN committees c 
    ON c.name = m.name;

同时检查 When to use single quotes, double quotes, and backticks in MySQL