?
Solved

SQL Query inner join?

Posted on 2008-06-18
3
Medium Priority
?
303 Views
Last Modified: 2010-08-05
Hi there, need a query to fit the below, I have a similiar query where I've used inner joins but this requires 'where' from multiple tables.

Here it is in pseudo (kind of):

Select EventTitle, EventDateTime FROM dbo.Events Where Event ID=@EventID

Select CustID, FullTickets, HalfTickets, FreeTickets, MembersTickets, Price, PaymentMethod, StaffID, Notes, BookingID WHERE EventID=@EventID FROM dbo.Bookings

Select FirstName + ' ' + LastName As Name from dbo.customers WHERE CustID=@CustID (all CustID returned from above Bookings table query)

I need this all to be returned in one row though, hope it makes sense!

Thanks!
0
Comment
Question by:garethh86
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
scgstuff earned 2000 total points
ID: 21818417
Try this:

Select e.EventTitle, e.EventDateTime, b.CustID, b.FullTickets, b.HalfTickets, b.FreeTickets, b.MembersTickets, b.Price, b.PaymentMethod, b.StaffID, b.Notes, b.BookingID, c.FirstName + ' ' + c.LastName As Name  
FROM dbo.Events e inner join dbo.Bookings s on e.EventID = b.Event_ID
inner join dbo.customers on b.CustID = c.CustID
WHERE e.EventID=@EventID

Shawn
0
 
LVL 7

Author Comment

by:garethh86
ID: 21818467
you got a couple of letters round the round way but i shuffled it round and it works! Thanks for the quick response! :)
0
 
LVL 5

Expert Comment

by:scgstuff
ID: 21818519
Sorry about that....was doing too much at once and wasn't watching what I was typing.

Thanks,

Shawn
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question