Help onGetting subcategoryname that share the same category but tied to another table

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2006
Posts: 21
Reputation: newMeg is an unknown quantity at this point 
Solved Threads: 0
newMeg newMeg is offline Offline
Newbie Poster

Help onGetting subcategoryname that share the same category but tied to another table

 
0
  #1
Feb 21st, 2008
Hi I have 3 tables in my database.
1) photo
2) category
3) subcategory

in my photo table i save my subcategoryid which is tied to the category table.

What i need to do is get the all the subcategoryname from subcategory table where photo.subcategoryid='1' and photoid='2'.

I can actually get the value, but what i want is also to display all the other values in subcategory table that share the same categoryid for the particular photoid.

lets say my photoid is 1 and my subcategoryid is 2 , so when check in category table , the categoryid for subcategory 2 is 3. How can i display other subcategories which is the same as categoryid 3

i hope my question is clear. Please help me on this.

eg


category table
categoryid
1
2
3
4

subcategorytable
subcategoryid
1
2
3
4

categoryid
1
1
2
2
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Help onGetting subcategoryname that share the same category but tied to another table

 
0
  #2
Feb 21st, 2008
Describe for me what's Photo, Category and Subcategory table?? the descrription of each of which I may help you!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Help onGetting subcategoryname that share the same category but tied to another t

 
0
  #3
Feb 21st, 2008
Question, why is your subcategory in your category table? Currently it is like this:
  1. Category
  2. / \
  3. Photos Subcategory
Why don't you make it like this:
  1. Category
  2. \
  3. Subcategory
  4. \
  5. Photos
Like this:
  1. Category
  2. - CategoryID
  3.  
  4. Subcategory
  5. - SubcategoryID
  6. - CategoryID
  7.  
  8. Photos
  9. - PhotoID
  10. - SubcategoryID
Last edited by SheSaidImaPregy; Feb 21st, 2008 at 5:05 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC