Selecting records from multiple tables
Posted: Mon Aug 26, 2002 3:26 am
Hi,
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:
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,
Shane McHale
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:
Code: Select all
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';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,
Shane McHale