如何处理看起来像 SQL 关键字的 SQL 列名? [英] How to deal with SQL column names that look like SQL keywords?

查看:21
本文介绍了如何处理看起来像 SQL 关键字的 SQL 列名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一列名为 from.我不能更改名称,因为我没有做到.我是否可以执行诸如 SELECT from FROM TableName 之类的操作,或者是否有特殊语法可以避免 SQL Server 被混淆?

One of my columns is called from. I can't change the name because I didn't make it. Am I allowed to do something like SELECT from FROM TableName or is there a special syntax to avoid the SQL Server being confused?

推荐答案

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

Wrap the column name in brackets like so, from becomes [from].

select [from] from table;

还可以使用以下内容(在查询多个表时很有用):

It is also possible to use the following (useful when querying multiple tables):

select table.[from] from table;

这篇关于如何处理看起来像 SQL 关键字的 SQL 列名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆