Forum Moderators: phranque

Message Too Old, No Replies

Coldfusion Question

         

kevinj

10:28 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



I have a client that has a table called Doctors and a field called Note. Unfortunately the Note field is not set up to deny duplicates so there are duplicate values in that field. Is there a way to set up the query to not grab duplicates but rather, just each possible value only once? My code so far is as follows:

<cfquery name="GetNotes" datasource="finder">
SELECT Note
FROM Doctors
WHERE Note <> ''
ORDER BY Note
</cfquery>

Thanks,

Kevin

txbakers

2:46 am on Aug 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure in ColdFusion, but in ANSI SQL you could use the DISTINCT keyword:

select DISTINCT field1,field2 from table

which would return only unique entries.

Slade

2:49 am on Aug 15, 2003 (gmt 0)

10+ Year Member



If the datasource is roughly ANSI compliant (or MS SQL, or MySQL) you can use distinct. The query is evaluated then passed on to the actual database engine.

kevinj

3:49 am on Aug 15, 2003 (gmt 0)

10+ Year Member



Yep, Distinct did the trick. Thanks very much.

Kevin

lorax

3:54 am on Aug 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> If the datasource is roughly ANSI compliant (or MS SQL, or MySQL) you can use distinct.

That's a useful tidbit I didn't know - thanks Slade.