我的一个专栏叫。我不能改名字,因为不是我做的。 我是否允许做一些像SELECT from TableName或有一个特殊的语法,以避免SQL Server混淆?


当前回答

将列名像这样用括号括起来,from变成[from]。

select [from] from table;

也可以使用以下命令(在查询多个表时很有用):

select table.[from] from table;

其他回答

简单的解决方案

假设列名是from;因此,查询中的列名可以通过表别名引用

Select * from user u where u.from="US"

下面的方法会很有效:

SELECT DISTINCT table.from AS a FROM table

将列名像这样用括号括起来,from变成[from]。

select [from] from table;

也可以使用以下命令(在查询多个表时很有用):

select table.[from] from table;

在Apache Drill中,使用反引号:

select `from` from table;

我也遇到过这个问题。 解决方案是在查询中像这样放入[Column_Name]。

string query= "Select [Name],[Email] from Person";

所以它会工作得很好。