Solved

SQL Query inner join?

Posted on 2008-06-18
3
297 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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
scgstuff earned 500 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

773 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