need help with an outer join? [message #970] |
Sun, 17 March 2002 09:58 |
Nancy
Messages: 19 Registered: March 2002
|
Junior Member |
|
|
I am very new to database development and could use some help on a problem.
I have 3 tables, (Groomers, Riders, Horses) The groomers and riders both link to the horses table. I want to find out the names of all the riders that are not assigned to horses. I think I need to use an outer join but have been running into difficulties. Help!
P.S. This is what I have:
SELECT rname, horses.riderid
FROM riders, horses
WHERE riders.riderid!=horses.riderid(+);
Thanks
|
|
|
Re: need help with an outer join? [message #971 is a reply to message #970] |
Sun, 17 March 2002 11:24 |
Mike
Messages: 417 Registered: September 1998
|
Senior Member |
|
|
Hi,
You can either do it like:
SELECT rname, riders.riderid
FROM riders, horses
WHERE riders.riderid=horses.riderid(+);
AND horsed.riderid IS NULL;
or like:
SELECT rname, riderid
FROM riders
WHERE riders.riderid NOT IN
(SELECT horses.riderid FROM horses);
I didn't try it out but it should work
HTH
Mike
|
|
|