0

I used Northwind database and test with following query :

SELECT *
  FROM products
  JOIN suppliers ON suppliers.supplierID = products.supplierID

and I got a red message like this :

Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "products.supplierID" could not be bound.

Can anyone shed some light ? many thanks,

2
  • you do not have supplierID in your products table..Did you check that? Commented Mar 19, 2012 at 3:35
  • I used Northwind database example from microsoft, and i check it with select supplierID from products -- it worked !, any idea for me ? Commented Mar 19, 2012 at 3:43

6 Answers 6

2
SELECT suppliers.supplierID,products.supplierID
  FROM products
  JOIN suppliers ON suppliers.supplierID = products.supplierID

You should have to explicitly say which supplierid you need to display in results..put the columns on conflict (mandatory) on select statement

Sign up to request clarification or add additional context in comments.

2 Comments

This is a good advice but using * cannot be an issue in this case (certainly not the reason behind the error in question).
@AndriyM : you are right, after i try SELECT * FROM products, suppliers , after that i run SELECT * FROM products JOIN suppliers ON suppliers.supplierID = products.supplierID . It work ?!
1

My only guess based on this error and your query is that there is no SupplierId in the Products table. I would check the schema first.

1 Comment

thanks @Justin Pihony for quick reply, i try to query SupplierId, select supplierID from products -- it work fine,
1

I've just run the nortwind db script and ran the query and it runs fine for me.

SELECT *
FROM products
INNER JOIN suppliers ON suppliers.supplierID = products.supplierID

Have a look at the products table, is the supplierId there? if so then make sure you are running your query against the right database.

can you run the below queries and are they running successfully? The third query is essentially a join in another way.

select SupplierID from Suppliers
go
select SupplierID from Products
go
select * from Products p , Suppliers s
where p.SupplierID = s.SupplierID

Comments

0

Instead Of SELECT * Write the appropriate columns you want to select from both table

like SELECT suppliers.supplierID,suppliers.name..etc

both tables contain supplierID that is why the error comes.

Comments

0

Check the collation settings of the database and if case sensitive check that you are using case sensitive data object names.

Comments

0

your code is creating amibiguity in selecting the columns in select list by "select * " it is not getting which table columsn need to be selected as there are two tables used after from clause..do one thing aliase tables and use aliased column names in select list instead of simple *

eg.

select a.* from test a inner join xyz b on a.id=b.id

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.