hello,
i allow my users to enter conversations with one another. if a new comment is posted in one of these conversations, then i would like all users involved to receive an email to let them know about the new comment. can i use SQL to query only the unique email addresses in a conversation? i tried LIMIT and that didn't work.
the way it stands now, users are sent an multiple emails (i only want each participating user to receive one email)...
SELECT testComment.email, testComment.comment_title FROM testComment WHERE testComment.comment_title = %s GROUP BY testComment.email
thank you!
SQL to get Unique Email
Moderator: General Moderators
-
ninethousandfeet
- Forum Contributor
- Posts: 130
- Joined: Tue Mar 10, 2009 4:56 pm
-
sujithtomy
- Forum Commoner
- Posts: 46
- Joined: Tue Mar 24, 2009 4:43 am
Re: SQL to get Unique Email
Hello,
Use DISTINCT keyword before fieldname
eg:
Good Luck 
Regards,
Sujith
Use DISTINCT keyword before fieldname
eg:
Code: Select all
SELECT DISTINCT email FROM table_name WHERE conditionRegards,
Sujith
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: SQL to get Unique Email
Please don't put links to your blog behind keywords.
-
ninethousandfeet
- Forum Contributor
- Posts: 130
- Joined: Tue Mar 10, 2009 4:56 pm
Re: SQL to get Unique Email
i tried using DISTINCT and it had no affect on my results... can you think of any other way to do it?
-
sujithtomy
- Forum Commoner
- Posts: 46
- Joined: Tue Mar 24, 2009 4:43 am
Re: SQL to get Unique Email
Hello,
I am not sure this way is correct, but unless you find a good answer you can try as follows,
get all email-ids to an array (php), use array_unique() —which Removes duplicate values from an array,
then pass result to mailing program.
Good Luck!!
Regards,
Sujith
I am not sure this way is correct, but unless you find a good answer you can try as follows,
get all email-ids to an array (php), use array_unique() —which Removes duplicate values from an array,
then pass result to mailing program.
Good Luck!!
Regards,
Sujith