Hi,
The sql statement stated at the bottom of this post currently returns:
Code:
1 : 10 : home 2 : 22 : office
3: 33 : home
3: 33: office
4: 44: home
5: 55: office
That's an contact id number, an contactperson id number and the type of adress that is in the database. The problem is only that if two types of adresses are listed in contactpersonsaddress I get two lines in the above result. And I would like to have "IF OFFICE ADDRESS THEN OFFICE ADRESS ELSEIF HOME ADRESS HOME ADRESS ELSE NOTHING"
Who can help me out? Suggest some good reference websites to learn more about these types of inner joins? Thanks in advance,
cK
Code:
SELECT contacts.id, contactpersons.id, contactpersonsadress.type FROM contactpersons
INNER JOIN contacts ON (contactpersons.id = contacts.id) AND ('client' = contacts.type)
INNER JOIN contactpersonsaddress ON (contactpersons.id = contactpersonsaddress.id) AND (('office' = contactpersonsaddress.type) OR ('home' = contactpersonsaddress.type))
ORDER BY ...