| | |
Help onGetting subcategoryname that share the same category but tied to another table
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2006
Posts: 21
Reputation:
Solved Threads: 0
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
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
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
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:
Why don't you make it like this:
Like this:
MS SQL Syntax (Toggle Plain Text)
Category / \ Photos Subcategory
MS SQL Syntax (Toggle Plain Text)
Category \ Subcategory \ Photos
MS SQL Syntax (Toggle Plain Text)
Category - CategoryID Subcategory - SubcategoryID - CategoryID Photos - PhotoID - SubcategoryID
Last edited by SheSaidImaPregy; Feb 21st, 2008 at 5:05 pm.
![]() |
Other Threads in the MS SQL Forum
- Previous Thread: configuring mySQL ODBC issue
- Next Thread: Problem in finding birthday from date of birth in SQL Server
| Thread Tools | Search this Thread |






