Results 1 to 2 of 2
Aug 26, 2002, 01:19 #1
- Join Date
- May 2002
- 0 Post(s)
- 0 Thread(s)
Selecting records from multiple tables
I have been trying to write a mySQL query to retrieve records from two or more tables. Each table has a field for groupID. I want to be able to select certain fields from each table and return them as a single record.
This is what I have so far:
SELECT affiliation.groupID,affiliation.group_name,church_gate.groups,church_gate.churches,e_matters.website_address,e_matters.website_password FROM affiliation,church_gate,e_matters WHERE affiliation.groupID=church_gate.groupID OR affiliation.groupID=e_matters.groupID OR affiliation.groupID='Clenorcon';
This works as long as there is an entry for that groupID in every table. However, if one of the tables does not have an entry, nothing is returned.
How can I change this script so that it returns the values in the other tables which do have entries and just ignores the on without entries?
Thanks in advance,
Aug 26, 2002, 05:55 #2
- Join Date
- Jul 2002
- Toronto, Canada
- 63 Post(s)
- 3 Thread(s)
sounds to me like you are asking for a left outer join
select affiliation.groupID , affiliation.group_name , church_gate.groups , church_gate.churches , e_matters.website_address , e_matters.website_password from affiliation left outer join church_gate on affiliation.groupID=church_gate.groupID left outer join e_matters on affiliation.groupID=e_matters.groupID where affiliation.groupID='Clenorcon'