Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 1 PK to many FK

Author  Topic 

jacisme
Starting Member

34 Posts

Posted - 2007-09-05 : 16:25:37
Firstly, thank you for your help!

SQL 2000, ASP.

I need to create a query using the following:

Table1
CompanyID (PK)
Company

Table2
GameID
Game
PublisherID (FK)
DeveloperID (FK)
Developer2ID (FK)

Table1 is, obviously, a list of companies; those companies are related to the publisher and developer columns in table2 (as shown above). The pub, dev and dev2 will mostly contain different companies from Table1. Is this possible? And if so, will someone assist me with a query that will retrieve all the column data for both tables. Lastly, perhaps there is a better layout for the db?

Thanks again,
JAC

jacisme
Starting Member

34 Posts

Posted - 2007-09-05 : 17:30:30
I have come up with the following query:

SELECT G.PublisherID, G.DeveloperID, G.Developer2ID, c1.Company, c2.Company, c3.Company
FROM (GU_Games G
INNER JOIN CompanyList c1
ON c1.CompanyID = G.PublisherID)
INNER JOIN CompanyList c2
ON c2.CompanyID = G.DeveloperID
INNER JOIN CompanyList c3
ON c3.CompanyID = G.Developer2ID

BUT, I am receiving an error, I believe I need additional delimitters?? Can someone please help?
Go to Top of Page

jacisme
Starting Member

34 Posts

Posted - 2007-09-05 : 17:50:04
Actually, the above is working. Thanks anyway! :)
Go to Top of Page
   

- Advertisement -