如何使用 SQL 命令行 select 标题中带有冒号的列?
How do you select a column with a colon in the title using the SQL command line?
查询的格式为:
SELECT id:id FROM companies_info WHERE tickerSymbol = '030610';
并产生错误:
Error in query (1064): Syntax error near ':ID FROM companies_all_info WHERE tickerSymbol = '030610'' at line 1
我没有更改列名的权限,所以有没有一种方法可以搜索该列,尽管名称中有冒号?
期望的结果是输出 table,其中包含相关股票代码的 ID 代码。 (最终结果将是搜索多个股票代码和多个 id 作为一个结果输出)
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 ("`")
http://dev.mysql.com/doc/refman/5.7/en/identifiers.html
用反引号括起来,像这样:
SELECT `id:id` FROM companies_info WHERE tickerSymbol = '030610';
查询的格式为:
SELECT id:id FROM companies_info WHERE tickerSymbol = '030610';
并产生错误:
Error in query (1064): Syntax error near ':ID FROM companies_all_info WHERE tickerSymbol = '030610'' at line 1
我没有更改列名的权限,所以有没有一种方法可以搜索该列,尽管名称中有冒号?
期望的结果是输出 table,其中包含相关股票代码的 ID 代码。 (最终结果将是搜索多个股票代码和多个 id 作为一个结果输出)
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 ("`")
http://dev.mysql.com/doc/refman/5.7/en/identifiers.html
用反引号括起来,像这样:
SELECT `id:id` FROM companies_info WHERE tickerSymbol = '030610';