How to deal with SQL column names that look like SQL keywords?

后端 未结 14 1285
温柔的废话
温柔的废话 2020-11-22 13:24

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

14条回答
  •  清歌不尽
    2020-11-22 13:38

    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;
    

提交回复
热议问题