Vikings Dood
Vikings Dood

Reputation: 51

The multi-part identifier could not be bound. 3 table join

USE pubs
SELECT DISTINCT L.au_fname, L.au_lname
FROM dbo.authors L, dbo.titles B
JOIN dbo.titleauthor C ON dbo.authors.au_id=C.au_id
INNER JOIN dbo.titleauthor C1 ON B.title_id=C1.title_id
WHERE B.price >= 13
ORDER BY L.au_lname ASC

The bolded dbo.authors in this code keeps producing the error below... I clearly don't understand aliases because i cannot for the life of me, determine what is wrong. I tried changing it to "L" but the same error happens. I didn't think a double join would be this hard.

To explain what I am trying to do here. I am trying to get information from table authors to display based on a WHERE statement on table titles. however they only have common PK's on a 3rd table named title author. There for I am trying to join all 3 tables together via the common PK's.

Upvotes: 1

Views: 850

Answers (1)

Pawan Kumar
Pawan Kumar

Reputation: 2011

At one location you are using cartesian product and at one location you are using joins..thats not allowed. You need to use like below- Add join conditions....I dont have ur column names.

USE pubs
GO


SELECT DISTINCT L.au_fname, L.au_lname
FROM dbo.authors L 
INNER JOIN dbo.titleauthor C ON L.au_id=C.au_id
INNER JOIN dbo.titles B ON B.title_id=C.title_id
WHERE B.price >= 13
ORDER BY L.au_lname ASC

Upvotes: 2

Related Questions