I am getting the below error for the below SQL query, I am pretty sure it has something to do with the Alias given to PostGl. I just don’t know how to correct it.
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 clause its not a valid sql syntax :
WHERE genLedger.AccountLink <> 161 OR genLedger.AccountLink <> 162 OR...
but you can use
not in instead:
WHERE genLedger.AccountLink not in (161,162,163,164,165,166,167,168,122)