Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 29th, 2004, 06:43 PM
plasma800 plasma800 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Houston
Posts: 407 plasma800 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 13 m 36 sec
Reputation Power: 5
Send a message via Yahoo to plasma800
Help with theory behind specific table design and sql select statements...

Ok, this might be a tad long but will make sense. Im putting together a DB of products to be browsed and eventually end up at a list of vendors for a specific item.

Right now im concerned with 3 tables. One table is a list of possible categories that a product could fall under. (ex. phones, ksu's, accessories, power supplies) The table is 2 column, catID and category.

The next table is a Manufacturer table, defines all of the possible manufactures/brands a product could fall under. Again 2 columns, ManuID and manu

Third table is the table of products them selves... 6 columns, prodID, item, model, manuID, catID and photo (for later use)

At this point, I am trying to build a list of CATERGORIES for a particular Manufacturer. Bascially, whatever of the who knows how many categories that happen have parts that fit that manufacturer, display the categories (then, each would be linked so that clikcing the cat provides a list of parts under that cat, which is under the manufacturer.. )

At this point, ive realized that the only place I tie the part and the category together is in the products table.

How'm i gonna display this list of matching categories now.
I would obviuosly have to run down the list of products and pull out each catID that matches the ManuID already specified. But as a think about that, this list of parts will eventually be prolly 10000 or more records deep.

Anyway, im trying to get the gist of the theory behind all this...

would I

Select CatID from PRODUCTS where manuID = SpecifiedManuID

and then... i dunno.. am i thinkin about this screwy,, can anyone point me in the direction of how to tie this together.. I just need to print the list of categories that have parts and match the manufacturer requested.

Reply With Quote
  #2  
Old March 29th, 2004, 07:07 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
To get the list of categories for a manufacturer, based on the products they sell, you could do something like this
Code:
SELECT A.Category
FROM categories
INNER JOIN Products As B On (A.CatID = B.CatID)
INNER JOIN Manufacturers As C On (B.ManuID = C.ManuID)
WHERE C.ManufacturerName = 'General Electric'

Reply With Quote
  #3  
Old March 29th, 2004, 07:24 PM
plasma800 plasma800 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Houston
Posts: 407 plasma800 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 13 m 36 sec
Reputation Power: 5
Send a message via Yahoo to plasma800
Cool

does the a b and c represent anything.... or are they just holders (buffers)...

Im really NOT trying to be freakin dense here... but i guess im just so new at this.

lemme breakdown the no bulls of it.
ManuID was passed from pervious page, so now i KNOW what manufacturer they would like to see categories for..

3 tables.
-------------
ttProduct : 'to hold info for each individual item
columns = ProdID, item, model, manuID, catID, photo
-------------
ttCategories : 'to hold the multitude of possible categories parts could fit under
cloumns = catID, category
-------------
ttManu : 'to hold all possible manufacturer / brand combos
columns = manuID, manu
-------------

so
catRs.open
"SELECT A.category
from ttCategories
INNER JOIN ttProducts As B on (A.catID = B.CatID)
INNER JOIN ttManu As C On (B.manuID = C.manuID)
WHERE C.manuID = " & manuID
------------
?? Now what kind of recordset is that going to give me....

cause see, now what i need to do is display the list of categories that match the bill for requested manu set in links to pass the category on to the next page, where now that I know the manuID and the CatID can display a list of products that fit BOTH in order to display a list of vendors that carry said product arranged by price lol i dunno what the **** im doing...

Reply With Quote
  #4  
Old March 29th, 2004, 07:31 PM
plasma800 plasma800 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Houston
Posts: 407 plasma800 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 13 m 36 sec
Reputation Power: 5
Send a message via Yahoo to plasma800
Im thnking that once i do this, now i have the the category field available to me in the recordset right...


so i can build links based on the catID and the manuID and display the category in the middle.. right?

Code:
response.write("<a href="vendorlist.asp?catID=" & catRs("catID") & "&manuID=" & manuID & ">" & catRs("Category") & "</a>")

Last edited by plasma800 : March 30th, 2004 at 02:21 AM.

Reply With Quote
  #5  
Old March 29th, 2004, 09:38 PM
plasma800 plasma800 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Houston
Posts: 407 plasma800 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 13 m 36 sec
Reputation Power: 5
Send a message via Yahoo to plasma800
Ok obviuosly by now, ive figured out that a means something else....

Its the AS part that gets me....

but i got part of it figured out..

I used this statment..
catRs.open "SELECT ttCategory.category from ttCategory INNER JOIN ttProducts on ttCategory.catID = ttProducts.CatID WHERE ttProducts.manuID = '" & manuID & "'",objCn, 1, 3

and then in the page
---------------

Dim x
do until catRs.EOF
for each x in catRs.fields
response.write(x.name)
response.write(" = ")
response.write(x.value & "<br>")
next
response.Write("<br>")
catRs.movenext
loop
-------------------------
And it returns obviuosly multiples of the same, for each time it finds it, it returns a row...

category = Phones

category = Phones

category = Cards, Processors and Addons

category = Cabinets, KSU's & Power Supplies

category = Cabinets, KSU's & Power Supplies

category = Voicemail Units
---------------------------------
Ok so great, I got that much, now i need to figure out how to display eachonly once, and then hook it into a link to the next page while passing the manuID and the catID

Last edited by plasma800 : March 30th, 2004 at 02:23 AM.

Reply With Quote
  #6  
Old March 30th, 2004, 02:17 AM
plasma800 plasma800 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Houston
Posts: 407 plasma800 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 13 m 36 sec
Reputation Power: 5
Send a message via Yahoo to plasma800
Dood im pluggin away here..

I got to here...

catRs.open "Select ttCategory.category, ttCategory.catID from ttCategory
INNER JOIN ttProducts AS Category on (ttCategory.catID = ttProducts.CatID)
INNER JOIN ttManu AS Products On (ttProducts.manuID = ttManu.manuID)
where manuID ='" & manuID & "'",objCn, 1, 3

Im thinking this all has to do with the select statement

I should end up with a recordset that merges all three tables first cat table and prod table based on cat id and then that new set to the manu table based on manuid between the two right? and only where that manuID = the page level manuID

but it tells me

Microsoft OLE DB Provider for SQL Server error '80040e14'

The column prefix 'ttProducts' does not match with a table name or alias name used in the query.

and will this select statement get me the results i need?

Reply With Quote
  #7  
Old March 30th, 2004, 07:12 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
A, B and C are just aliases for the table names, so you don't have to type (Manufacturer.ManuID) you just do (INNER JOIN Manufacturer As C), then you can just use C.fieldname, to represent the fieldname to pull from the manufacturers table.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Help with theory behind specific table design and sql select statements...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT