Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining two tables effectively

Status
Not open for further replies.

jimstuart

Programmer
Nov 16, 2007
1
GB
Hi all,

I'm trying to retrieve information in the most useful way but can't seem to find a way that seems right. Sure I'm missing something.

My tables -

room_bookings -

number | startTime | endTime | employee
1 | | |
2 | | |
3 | | |

booking_clashes -

number | clasheswith
1 | 2
1 | 3
2 | 3


The clashes are created if somebody has booked a room that overlaps with somebody else's booking. As you can see there can be multiple clashes.

I'd like to be able to do some sort of join between these tables so that I can select from the room_bookings and have the clashes in with that row.

Hope that makes sense,
Jim
 
Code:
SELECT rb.Number, rb.StartTime --Add in whatever else you want to select
FROM room_bookings rb
WHERE rb.Number IN (SELECT NUMBER FROM booking_clashes)

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top