Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Problem joining 3 tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-29 : 09:29:49
Brian writes "Hello,

I have 3 tables (images, galleries, imageGallery) with the following structure:

Images: imageID, imageYear, imageMonth, imageName
Galleries: galleryID, headline, synopsis
ImageGallery: ID, imageID, galleryID

A given Photo Gallery could have any number of images and a specific image could theoretically belong to more than one gallery. I'm using the ImageGallery table to associate images with galleries.

I'm trying to build an Image Gallery ASP index page that pulls in the headline and 1 image (it can be any image that's associated with that particular gallery) for the latest 5 galleries. The headline and image will be links to the actual gallery.

I'm sure I need to use some sort of nested SQL query to accomplish this, but nothing I've tried has worked. The many-to-many relationships here are really throwing me off. Any help would be greatly appreciated. Thanks in advance!

Brian"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-05-29 : 09:39:45

...
from
images i
inner join imagegallery ig
on i.imageid = ig.imageid
inner join galleries g
on ig.galleryid = g.galeryid
...

 


<O>
Go to Top of Page
   

- Advertisement -