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)
 returning image urls and defaults

Author  Topic 

returnofthemack
Starting Member

16 Posts

Posted - 2003-05-19 : 14:12:43
I have a database of products and images, such that each product can have multiple images (small, med, large). For a particular query, I'm trying to return all products (name, etc.) along with their small image URL. If the product does not have a small image (in other words, if it has a large or med image - or both - or if it has no image associated with it), I want to return a default image url, such as '/images/nophoto.gif'.

I'm able to obtain a list of products, regardless of whether or not it has an image associated with it by using a left join. However, I'm having problems with products that have both a large and small image, in which case I receive two entries for the product - the small image URL and the 'nophoto.gif' url.

Tables are something like this:

Products - ID, name, price
Products_Images - ProductID, ImageID
Images - ID, ImageType, URL

Again, the problem I'm having is for images that have both small and large images.

Thanks in advance for your help!

mikejohnson
Posting Yak Master

153 Posts

Posted - 2003-05-19 : 15:14:46
I would add an additional field on your images table saying what type of image it is. I would also add an imagetype table to describe the choices your user has. example, small;medium;large;

Then design your program to read the imagetype table for choices. Then in the future it will be easy to add new types.

Go to Top of Page

returnofthemack
Starting Member

16 Posts

Posted - 2003-05-19 : 16:12:57
Sorry, I was trying to keep the example simple - I do have a type table, as you explained. If I remember right, the typeID that references the type table is in the images table. I am able to check for the particular type, but again, the problem I'm having is returning the unique rows for those images that have two types - large, small, etc.

Help anyone?

Go to Top of Page
   

- Advertisement -