User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 427,193 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,200 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 369 | Replies: 2
Reply
Join Date: Jul 2006
Posts: 17
Reputation: newMeg is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
newMeg newMeg is offline Offline
Newbie Poster

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

  #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

AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

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

  #2  
Feb 21st, 2008
Describe for me what's Photo, Category and Subcategory table?? the descrription of each of which I may help you!
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

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

  #3  
Feb 21st, 2008
Question, why is your subcategory in your category table? Currently it is like this:
       Category
      /        \
Photos          Subcategory
Why don't you make it like this:
     Category
             \
               Subcategory
                           \
                            Photos
Like this:
Category
- CategoryID

Subcategory
- SubcategoryID
- CategoryID

Photos
- PhotoID
- SubcategoryID
Last edited by SheSaidImaPregy : Feb 21st, 2008 at 4:05 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 10:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC