Advertisement

09.05.2008 at 03:56PM PDT, ID: 23707968
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

Selecting from multiple tables using foreign keys

Asked by coanda in SQL Query Syntax, MS SQL Server, SQL Server 2005

Tags: ,

It's been a while since I've had to do any database development so if what I've done seems ridiculous please feel free to let me know. I've taken a spreadsheet and tried to convert it into a set of database tables, from what little about database development that I remember you're supposed to normalized your tables anywhere that there's a potential for repeating information.

I'm going to give a condensed version of my database tables so I don't need to type out a lot here

Tables:

Items
Columns(
  ItemID INT - PK
  CategoryID INT - FK
  TypeID INT - FK
  SupplierID - FK
  ItemName VARCHAR
  PurchaseDate DATETIME
)

Categories
Columns(
  CategoryID INT - PK
  CategoryName VARCHAR
)

Types
Columns(
  TypeID INT - PK
  TypeName VARCHAR
)

Suppliers
Columns(
  SupplierID INT - PK
  SupplierName VARCHAR
)

The Categories, Types, and Suppliers tables have been populated with data and what I'd like to do know is generate a query or stored procedure that will give me an output table like:

CategoryName | TypeName | SupplierName | ItemName | PurchaseDate
...

when I pass in a value for CategoryID/TypeID/SupplierID to the query/SP. I tried to do:

SELECT Categories.CategoryName, Types.TypeName, Suppliers.SupplierName, etc
   FROM Categories, Types, Suppliers, Items
WHERE Items.CategoryID = {integer value}

but this runs off into a never ending (I think) query that I had to cancel when it reached 20000+ records. Any advice on this would be greatly appreciated. Thanks.Start Free Trial
 
Loading Advertisement...
 
[+][-]09.05.2008 at 04:16PM PDT, ID: 22404564

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, MS SQL Server, SQL Server 2005
Tags: SQL, SQL Server 2005
Sign Up Now!
Solution Provided By: dnsvh
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.05.2008 at 04:19PM PDT, ID: 22404581

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.05.2008 at 09:33PM PDT, ID: 22405926

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2008 at 09:35PM PDT, ID: 22405939

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628