【问题标题】:How to select "Group" column name from another table in an SQL Server?如何从 SQL Server 中的另一个表中选择“组”列名?
【发布时间】:2021-11-06 04:12:41
【问题描述】:

组是表之一中的列。 我正在使用以下查询。由于 Group 是保留关键字,因此在执行以下查询时出错:

select o.group as group,
 p.id as id 
from
product p left join org o on p.id=o.id

谁能指导一下?

【问题讨论】:

  • 简单——只要不使用保留关键字作为对象名称,你就不会遇到这个问题; select o.group as ProductGroup, - 已修复。

标签: sql sql-server reserved-words


【解决方案1】:

常规 SQL Server 方式:

select o.[group] as [group],

而且 SQL Server 也支持 ANSI SQL 方式(可能需要一些设置?)

select o."group" as "group", 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-07
    相关资源
    最近更新 更多