无法绑定多部分标识符 "genLedger.AccountLink"。 (4104) (SQLExecDirectW)

The multi-part identifier "genLedger.AccountLink" could not be bound. (4104) (SQLExecDirectW)

下面的 SQL 查询出现以下错误,我很确定它与给 PostGl 的别名有关。就是不知道怎么修改。

查询:

all =  'SELECT Master_Sub_Account , cAccountTypeDescription , Debit , Credit FROM [Kyle].[dbo].[PostGL] AS genLedger'\
                    'Inner JOIN [Kyle].[dbo].[Accounts] '\
                    'on Accounts.AccountLink = genLedger.AccountLink '\
                    'Inner JOIN [Kyle].[dbo].[_etblGLAccountTypes] as AccountTypes '\
                    'on Accounts.iAccountType = AccountTypes.idGLAccountType'\
                    ' WHERE genLedger.AccountLink not in (161,162,163,164,165,166,167,168,122)'

错误:

The multi-part identifier "genLedger.AccountLink" could not be bound. (4104)

at where 子句不是有效的 sql 语法:

WHERE genLedger.AccountLink <> 161 OR genLedger.AccountLink <> 162 OR...

但您可以使用 not in 代替:

WHERE genLedger.AccountLink not in (161,162,163,164,165,166,167,168,122)