Gossamer Forum
Home : General : Databases and SQL :

Limit Inner Join

Quote Reply
Limit Inner Join
 
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 ...
Subject Author Views Date
Thread Limit Inner Join cK 12859 Nov 2, 2003, 7:52 AM
Thread Re: [cK] Limit Inner Join
cK 12406 Nov 4, 2003, 2:46 PM
Thread Re: [cK] Limit Inner Join
cK 12392 Nov 8, 2003, 8:04 AM
Thread Re: [cK] Limit Inner Join
Stealth 12332 Nov 8, 2003, 10:58 AM
Post Re: [Stealth] Limit Inner Join
cK 12282 Nov 8, 2003, 1:32 PM