Wednesday 12 February 2014

MSSQL - How to fix error - The multi-part identifier "Cities.CityID" could not be bound.


watch this example on YouTube





Replace
select * from Countries Inner Join

Customers ON Cities.CityID = Customers.CityID Inner Join

Cities ON Cities.CountryID = Countries.CountryID

with

select * from Countries Inner Join

Cities ON Cities.CountryID = Countries.CountryID Inner Join

Customers ON Cities.CityID = Customers.CityID

basically - order is very important, in my case I have 3 tables
Countries,Cities,Customers
Countries can have 0,1 or more Cities
Cities can have 0,1 or more Customers
in my INNER JOIN I cannot reference Customers before Cities.