Inner Join - add a sub-innerjoin to one of the referenced tables?
am 12.09.2005 16:06:57 von jason
Is there a way to extend this Inner Join to allow me to join a FK in one of
the tables referenced below ie 'Company'?
CREATE Procedure spr_GetStatusRequest
@BoatID int
As
set nocount on
Select *
FROM StatusRequest
INNER JOIN Company ON
StatusRequest.CompID = Company.CompanyID
WHERE StatusRequest.BoatID= @BoatID
return
GO
....Inside Company is a field called CategoryID which looks up its
corresponding field CategoryID inside table CATEGORY. Is it possible to also
'JOIN' this table to the the query above....I have no idea how to do this?
Much appreciated
Jason
Re: Inner Join - add a sub-innerjoin to one of the referenced tables?
am 12.09.2005 16:44:07 von reb01501
jason@catamaranco.com wrote:
> Is there a way to extend this Inner Join to allow me to join a FK in
> one of the tables referenced below ie 'Company'?
Why not? See below.
>
> CREATE Procedure spr_GetStatusRequest
> @BoatID int
> As
> set nocount on
> Select *
Don't use selstar! Especially when joining tables!!
http://www.aspfaq.com/show.asp?id=2096
> FROM StatusRequest s
> INNER JOIN Company c ON
> s.CompID = c.CompanyID
INNER JOIN CATEGORY cat ON
cat.CategoryID = c.CategoryID
> ...Inside Company is a field called CategoryID which looks up its
> corresponding field CategoryID inside table CATEGORY. Is it possible
> to also 'JOIN' this table to the the query above....I have no idea
> how to do this?
Really? Time to hit one of the many books about SQL on the market. I've
heard good things about Ken Henderson's book.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.