October 21, 2013 at 4:46 am
Hi all,
I'm new to SQL and would like to join specific columns that form part of 3 specific tables (GuestNameInfo, GuestStaySummary, ResrvationStay).
The common column (not necessarily the Primary Key or Foreign Key) found in all the above 3 tables is called "ReservationStayID".
I've been able to write the query to join 2 tables (see below) but can't find the right syntax to join the 3 tables.
The columns needed for the 3rd table (ie: Reservation Stay) are AdultCount, ChildCount, SourceCode.
Select a.FirstName,a.LastName,a.ArrivalDate,a.DepartureDate,a.CreatedOn,b.ProfileId,b.ReservationStatus,b.MarketSegmentCode,b.Nights,b.GuestCount
From GuestNameInfo a
JOIN GuestStaySummary b on a.ReservationStayID = b.ReservationStayID
Thank you for your help!
October 21, 2013 at 4:55 am
Select a.FirstName,a.LastName,a.ArrivalDate,a.DepartureDate,a.CreatedOn,b.ProfileId,b.ReservationStatus,b.MarketSegmentCode,b.Nights,b.GuestCount,c.AdultCount, c.ChildCount, c.SourceCode
From GuestNameInfo a
JOIN GuestStaySummary b on a.ReservationStayID = b.ReservationStayID
JOIN ResrvationStay c on c.ReservationStayID = b.ReservationStayID
hope it helps
October 21, 2013 at 5:24 am
It works!! Thanks a lot, twin.devil!:-)
October 21, 2013 at 5:30 am
u r welcome
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy