dennisbekkering
Programmer
Hello everybody,
I have to following query
SELECT DISTINCT A0.*
FROM Mail A0
INNER JOIN MailTo2Contact A1 ON A0.id=A1.mailid
INNER JOIN Contact A2 ON A1.contactId=A2.id
LEFT OUTER JOIN MailCc2Contact A3 ON A0.id=A3.mailid
LEFT OUTER JOIN Contact A4 ON A3.contactId=A4.id
LEFT OUTER JOIN MailBcc2Contact A5 ON A0.id=A5.mailid
LEFT OUTER JOIN Contact A6 ON A5.contactId=A6.id
WHERE ( A2.companyid = ? OR (A4.companyid = ?)
OR (A6.companyid = ?)) AND (A0.flag = 'sent') ORDER BY 6 DESC
it gives me all the mail (to,cc and bcc) from all contacts belonging to a certain company. When i make all the joins inner joins then i dont get any results. The to,cc&bcc joins are then AND-ed istead of OR-ed. I dont't understand why. Thanks in advance for reactions.
bye,
Dennis
I have to following query
SELECT DISTINCT A0.*
FROM Mail A0
INNER JOIN MailTo2Contact A1 ON A0.id=A1.mailid
INNER JOIN Contact A2 ON A1.contactId=A2.id
LEFT OUTER JOIN MailCc2Contact A3 ON A0.id=A3.mailid
LEFT OUTER JOIN Contact A4 ON A3.contactId=A4.id
LEFT OUTER JOIN MailBcc2Contact A5 ON A0.id=A5.mailid
LEFT OUTER JOIN Contact A6 ON A5.contactId=A6.id
WHERE ( A2.companyid = ? OR (A4.companyid = ?)
OR (A6.companyid = ?)) AND (A0.flag = 'sent') ORDER BY 6 DESC
it gives me all the mail (to,cc and bcc) from all contacts belonging to a certain company. When i make all the joins inner joins then i dont get any results. The to,cc&bcc joins are then AND-ed istead of OR-ed. I dont't understand why. Thanks in advance for reactions.
bye,
Dennis