I am very unfamiliar with INNER AND OUTER JOIN operations,
and have a problem when constructing an LEFT OUTER JOIN, for
the first time.
First the table's
-----
TblClients
Cli_Id primary key
Cli_FName
Cli_LName
....
TblSag
Sag_Id primary key
Sag_txt
Sag_Cli_Id references TblClients(Cli_Id)
....
TblSagOpponents
Sgo_Id primary key
Sgo_CaseNo
Sgo_sag_id references TblSag(Sag_Id)
Sgo_Opp_Id references TblOpponents(Opp_Id)
.....
TblOpponents
Opp_Id primary key
Opp_FName
Opp_LName
....
--------
Every record in TblSag has a reference in TblClients.
Every record in TblSagOpponents has a reference in Opponents.
There are many record in TblSag who have no records in
TblsSagOpponent.
My idea is to retrieve all records form TblSag and only
those of TblSagOpponent that match the search condition in
the ON clause.
The following Select statement works fine and retreives all the
records in TblSag and only those in TblSagOpponents which have a
matching record.
----------
SELECT
Sag_Id, Sag_Txt //from TblSAG
Cli_FName,Cli_LName //from TblClients
Sgo_CaseNo,Sgo_Opp_Id //from TblSagOpponents
FROM
TblClients, TblSag LEFT OUTER JOIN TblSagOpponents
ON Sgo_Sag_Id = Sag_Id
WHERE
Sag_Cli_Id = Cli_Id
ORDER BY
SAG_ID
----------
What i want to do is to expand the Select statement to retreive
the fields Opp_FName and Opp_LName from TblOpponent, but i cannot
figure out how to do it.
The following query works but now not all the records in TblSag are
retreived but only those where there is a record in TblSagOpponent.
I know that this is because of the wrong Where-clause, but how shall
i do it ?
---------
SELECT
Sag_Id, Sag_Txt //from TblSAG
Cli_FName,Cli_LName //from TblClients
Sgo_CaseNo,Sgo_Opp_Id //from TblSagOpponent
Opp_FName,OPP_LName //from TblOpponent
FROM
TblClients,TblOpponent, TblSag LEFT OUTER JOIN TblSagOpponent
ON Sgo_Sag_Id = Sag_Id
WHERE
Sag_Cli_Id = Cli_Id
Sgo_Opp_Id = Opp_Id
ORDER BY
SAG_ID
I would be very happy if anyone could help me with this question
Regards
Magnus