You are here: Re: Need help Joining tables « MsSQL Server « IT news, forums, messages
Re: Need help Joining tables

Posted by Roy Harvey (SQL Server MVP) on 10/24/07 17:05

On Wed, 24 Oct 2007 09:08:25 -0700, JJ297 <nc297@yahoo.com> wrote:

>The key for the titleclassification table
>is titleclassID

Then either I do not understand the purpose of the table (likely, as I
can only guess) or the table had an ID column stuck on as a key out of
blind reflex. My assumption was that it was a "junction" table used
to make a many-to-many relationship between title and classification.
Such a table would properly have a key consisting of the key column(s)
of the Titles table plus the key column(s) of the Classifications
table.

>When I entered what you wrote in query analyzer I got...
>
>The column prefix 'classifications' does not match with a table name
>or alias name used in the query.

I missed changing one reference to use the alias.

SELECT A.titleid,
A.title,
A.[description],
B.quantityowned,
D.[description]
FROM Titles as A
JOIN resources as B
ON A.titleid = B.titleid
JOIN titleclassification as C
ON A.titleid = C.titleid
JOIN classifications as D
ON D.classificationid = C.classificationid

Roy Harvey
Beacon Falls, CT

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация