Help with query with conditions
Hi,
I am trying to run the following query. In this query it shows all contacts with an email address but does not show the ones without an email address. This is because of the second to last line "AND contacts.id = email_addr_bean_rel.bean_id". What I need is to run all the lines except this one. Then also run all the lines with this one and put the 2 pieces of data together so I have the contacts with and without email addresses. Is there a way to do this with some sort of case/if statement or what would be the best way to go about this? I am doing this right from a command line.
Thanks!
accounts_cstm.result_status_date_c,accounts_cstm.Listsource_c, accounts_cstm.product_interest_c,accounts.name,contacts.first_name,contacts.last_name, contacts.title,contacts.phone_work, email_addresses.email_address, contacts.primary_address_street,contacts.primary_address_city, contacts.primary_address_state, contacts.primary_address_postalcode,primary_address_country,notes.description
FROM notes, accounts, accounts_cstm, contacts, accounts_contacts,email_addr_bean_rel, email_addresses
WHERE accounts.id = accounts_cstm.id_c
AND accounts_contacts.contact_id = contacts.id
AND accounts_contacts.account_id = accounts.id
AND notes.contact_id = contacts.id
AND accounts_cstm.result_status_c LIKE 'Qualified Lead%'
AND contacts.id = email_addr_bean_rel.bean_id
GROUP BY contacts.last_name