Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 保留字字段名称表别名查询_Sql_Sql Server 2008_Syntax Error - Fatal编程技术网

Sql 保留字字段名称表别名查询

Sql 保留字字段名称表别名查询,sql,sql-server-2008,syntax-error,Sql,Sql Server 2008,Syntax Error,我有一个带有字段“value”的表“x”。如果将此字段括在括号中,则可以查询它。例如: select x.[value] from x 问题是我需要在这个表有别名的地方进行多部分联接 当我将该表别名如下: select foo.[value] from x as 'foo' 这与: Incorrect syntax near 'foo'.... 1 statement(s) executed 如果建造这张桌子的人没有使用保留字,那就太棒了,但我没那么幸运!对这里可能有用的语法有什么想法吗

我有一个带有字段“value”的表“x”。如果将此字段括在括号中,则可以查询它。例如:

select x.[value] from x
问题是我需要在这个表有别名的地方进行多部分联接

当我将该表别名如下:

select foo.[value] from x as 'foo'
这与:

Incorrect syntax near 'foo'.... 1 statement(s) executed
如果建造这张桌子的人没有使用保留字,那就太棒了,但我没那么幸运!对这里可能有用的语法有什么想法吗

如果有帮助,“value”是一个VARCHAR(100)。

使用[]而不是'

select foo.[value] from x as [foo]
或者只是写

select foo.[value] from x as foo

有趣的是,我在你发帖之前就知道了。很高兴给你支票。谢谢