Thanks Bud, this seems the best option and works well.

Cheers

Will

----- Original Message -----
From: "Bud" <[EMAIL PROTECTED]>
Newsgroups: cf-talk
Sent: Tuesday, June 12, 2001 3:56 PM
Subject: Re: Correct use of "distinct" in queries


> On 6/12/01, W Luke penned:
> >I'm trying to do the most basic of queries.  Select distinct email
addresses
> >from a table, and email them using cfmail.  But for some reason it's not
> >pulling unique addresses - is this because I have a WHERE statement?
> >
> >  <cfquery name="getothers" datasource="LBTalk">
> >  SELECT distinct comEmail, comDate FROM comments
> >  WHERE comEmail <> '#form.email#'
> >  AND comAdID = #form.adID#
> >  </cfquery>
> >
> >[EMAIL PROTECTED] has 4 entries with form.adID in the table comments -
but
> >he should only receive one email.
> >
> >Any suggestions appreciated
>
> When you use DISTINCT, it will only bring up distinct records for the
> fields you have defined. So in this case, if comDate is not also the
> same for each record, then you have 4 distinct records.
>
> Use <cfmail query="getothers" group="comEmail">
>
> Then you can nest a cfoutput in the cfmail body if you want to show
> all 4 comDates for that email address.
>
> <cfmail query="getothers" group="comEmail"
> from="blah"
> to="blah"
> subject="blah">
> You received email on these dates:
> <cfoutput>#dateformat(comDate)#
> </cfoutput>
> --
>
> Bud Schneehagen - Tropical Web Creations
>
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> ColdFusion Solutions / eCommerce Development
> [EMAIL PROTECTED]
> http://www.twcreations.com/
> 954.721.3452
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to