OK, I am having difficulties with this query, What I want to do is join titles.pub_id to publishers.pub_id and then join publishers.pub_id onto employee.pub_id.
This is what I have came up with so far
In the titles table
title_id is the primary key
pub_id is a foreign key
In the publishers table
pub_id is the primary key
pub_name is a canidate key
in the employee table pub_id is a foreign key
SELECT titles.title_id
FROM titles
INNER JOIN titleauthor on titleauthor.title_id = titles.title_id
--INNER JOIN employee on employee.pub_id = publishers.pub_id
--INNER JOIN publishers on publishers.pub_id = titles.pub_id
The error that I get from this query is
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "publishers.pub_id" could not be bound.
Joins are left-associative, so an
ONclause can only refer to tables that are joined earlier in the query, not to tables that are joined later. So you need to change the order of these two lines:giving this:
in order that
on employee.pub_id = publishers.pub_idnot refer topublishersbefore it’s joined.