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
Microsoft SQL Server

Avatar of undefined
Last Comment
AbhishekSharma
ASKER CERTIFIED SOLUTION
Avatar of Nightman
Nightman
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo