SQL join using USING: <column name> is not a recognized table hints option

断了今生、忘了曾经 提交于 2019-12-24 21:13:40

问题


I have the following JOIN:

SELECT * FROM tableA INNER JOIN tableB USING (commonColumn)

I get an error:

"commonColumn" is not a recognized table hints option. If it is intended as a parameter to a table-valued function or to the CHANGETABLE function, ensure that your database compatibility mode is set to 90.

The following instead works:

SELECT * FROM tableA INNER JOIN tableB ON tableA.commonColumn = tableB.commonColumn

The compatibility level in my case is set to 100 (SQL Server 2008), while, by the way, I am working with SQL Server 2012.

What am I doing wrong? I find it very difficult to find example of the use of the keyword USING, as it is almost impossible to do a relevant web search. Yet, it seems the right thing to use when the "joining columns" have the same name...


回答1:


The USING keyword is used to specify the source data for MERGE statements (called <table source>) in the documentation.




回答2:


USING is not supported SQL Server syntax. It's not a reserved keyword, either, so the query engine is using that as a table alias.

It is an ODBC keyword, but those are handled somewhat differently. The engine won't always complain if you use them, but you're not supposed to use them anyways.

It is also listed as a possible future reserved keyword. It's common for new editions of SQL Server to add words to the core reserved list.

Personally, I don't see them adding NATURAL JOIN syntax support, even with USING. A lot of DBAs consider NATURAL JOINs problematic.



来源:https://stackoverflow.com/questions/32479936/sql-join-using-using-column-name-is-not-a-recognized-table-hints-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!