Send an e-mail to one person who has multiple products
Posted on 2009-05-06
I have asked this question before, but I am still having issues with writing this query.
What I have is a database with 5 or 6 tables that are all related via a couple of keys. When the query is ran, you get a list of results composed of the following fields:
" Client name
" Client Key
" Primary Key
" Client Key
" Model Key
" First name
" Last name
" Phone numbers
The problem is that one customer could have 80 products and with the current SQL would receive 80 e-mails. Is there a way to include all of their products in 1 shot without sending them 80 e-mails.
SELECT DISTINCT (AED_Master.ACT_no) AS Expr1, Client.ACT_no, *
FROM (((Contacts RIGHT JOIN Client ON Contacts.ACT_No=Client.ACT_no)
LEFT JOIN AED_master ON Client.ACT_no=AED_master.ACT_No)
LEFT JOIN Models ON AED_master.Model_ID=Models.Model_ID)
LEFT JOIN Cat_Sub ON Client.CatSub_id = Cat_Sub.CatSub_id
With the above SQL, I am still getting duplicate results. I need to tame this so it is one contact/multiple products.
I can upload the Database if that would help, just let me know. I am hoping this can be solved via a simple SQL variation, or if someone can write it for me and let me know why/what we did that?