Link to home
Start Free TrialLog in
Avatar of attipa
attipaFlag for United States of America

asked on

multiple column information in one stored procedure

i have the following stored procedure right now....

select i.PGImageID, i.Headline, i.Description, i.PGImageURL
from PGImage i
Inner Join PGGallery g ON i.PGImageID = g.Image1

Where g.GalleryID = (Select TOP 1 GalleryID From PGGallery ORDER BY DateAdded DESC)


The PGGallery table has the following columns: Image1, Image2, Image3, Image4, Image5
I am trying to get the information for each image like I have done for Image1 in the stored procedure above.
Is this possible to do it all in one stored procedure???  Please, someone help me asap because i am on a tight deadline.

thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Nightman
Nightman
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try or condition in ON Seciton

select i.PGImageID, i.Headline, i.Description, i.PGImageURL
from PGImage i
Inner Join PGGallery g ON (i.PGImageID = g.Image1 or i.PGImageID = g.Image2 or i.PGImageID = g.Image3 or i.PGImageID = g.Image4 or i.PGImageID = g.Image5)
Where g.GalleryID = (Select TOP 1 GalleryID From PGGallery ORDER BY DateAdded DESC)
or use Union All function
Hey attipa...have you tried my solution