If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Need help with a 3 table query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-29-02, 06:32
Ballonier Ballonier is offline
Registered User
 
Join Date: Oct 2002
Posts: 3
Need help with a 3 table query

Hi all,

I need some help with a query (SQL Server 7.0):
I have 3 tables:

tbl_trainer_bookings
.trainer_booking_id PK
.slot_id
.trainer_id

tbl_slots
.slot_id PK

temp1 (temporary table, trainer_id could be considered PK)
.trainer_id

I need a list of all combinations of
trainer_id and slot_id that are not in
tbl_trainer_bookings.

Hope this is a clear enough explanation,
and that somebody will be able to help me!

Regards,

Ballonier
Reply With Quote
  #2 (permalink)  
Old 10-29-02, 08:13
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Need help with a 3 table query

That's easy:

SELECT trainer_id, slot_id
FROM temp1, tbl_slots
MINUS
SELECT trainer_id, slot_id
FROM tbl_trainer_bookings ;
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On