简体   繁体   English

多部分标识符无法绑定

[英]The multi-part identifier could not be bound

$query = "SELECT cc.countryCode, m.stfMode 
          FROM test t LEFT JOIN countryCode cc ON t.idcountryCode=cc.idcountryCode LEFT JOIN mode m ON t.idmode=m.idmode 
          WHERE t.idtest=".$idtest;

When i am executing the above query I am getting the below error 当我执行上述查询时,出现以下错误

Warning: mssql_query(): message: The multi-part identifier ".countryCode" could not be bound. 警告:mssql_query():消息:无法绑定多部分标识符“ .countryCode”。

Please help.... 请帮忙....

使用Select cc.idcountryCode而不是SELECT cc.countryCode

In your Query countryCode is Used for both Tablename and a Column in that table. 在查询中, countryCode既用于表名,又用于该表中的列。 Please change the tablename or that ColumnName of countryCode Table 请更改表名或countryCode表的ColumnName

Your SQL should look like below 您的SQL应该如下所示

SELECT 
cc.idcountryCode, m.stfMode 
FROM test t 
LEFT JOIN countryCode cc 
ON t.idcountryCode=cc.idcountryCode 
LEFT JOIN mode m ON t.idmode=m.idmode 

WHERE t.idtest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM