|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to adjust this code to No duplicate e-mail
Hi all,
I've got a query that result in sending e-mail notifications to the persons based on the where statement. It works perfect. The only problem is that the table (gebruikers) holds all the reply's on a specific article, so if a user has replied 6 times to the same article and the selectdatum is set to 'Y' , i get 6 e-mails. So my question is how can i adjust the code and send only one match instead of 6... <cfquery name="emailadressen" datasource="spirilog"> SELECT email FROM gebruikers WHERE selectdatum = 'Y' and onderwerpid = '#url.id#' </cfquery> <cfmail query="emailadressen" from="info@aquarius.eu" to="#emailadressen.email#" bcc="" subject="Nieuwe reactie op Aquarius.eu" > </cfmail> I hope this is understandable explained. Anyone knows? ![]() |
|
#2
|
|||
|
|||
|
<cfquery name="emailadressen" datasource="spirilog">
SELECT DISTINCT email FROM gebruikers WHERE selectdatum = 'Y' and onderwerpid = '#url.id#' </cfquery> However, a deeper question is why are there duplicate email addresses in the database in the first place. If email should be unique, you should place a unique constraint on that column so that duplicates cannot be inserted.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
That's perfect! Thanks
Well, there are duplicate e-mail adresses in that table because it's a table that contains reply's to articles, so a user can reply as many times as he/she wishes and every time a emailadres is entered. Maybe there's another or better contruction, but this is the only way i can think of... ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > How to adjust this code to No duplicate e-mail |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|