Re: problem using DISTINCT
On 16 Aug, 16:39, "brianism" <[email protected]> wrote:
> Wondering if someone could guide me in the right direction. I have a query
> searching a database that I would like to return non-duplicate results.
> Problem is I keep getting duplicates. This is what I do:
> <cfquery name="getstroke" datasource="mydb">
> SELECT DISTINCT max_stroke_mm, wh_standard FROM presses WHERE model_head LIKE
> '#headmodel#%' ORDER BY wh_standard
> This searches the database to find all of the results that have the same
> model_head. Then it spits out the variable max_stroke_mm, and then it checks
> the field to see if wh_standard is true or not and displays it in green.
> <select style="padding:0px;margin:0px;" name="max_stroke_mm">
> <cfoutput query="getstroke">
> <option <cfif wh_standard EQ "yes">style="background-color:
> 00FF00"</cfif> value="#max_stroke_mm#">#max_stroke_mm# mm (standard)</option>
> My problem is I am getting duplicates results that I do not want like this:
> 100 mm
> 100 mm (standard)
> 200 mm
> 200 mm (standard)
> 300 mm
> 400 mm
> What I need is if it is standard to show once and not show the non-standard
> variable. I know it is pulling it out twice because it sees one result with
> #wh_standard# containing something and one result without. Anyone know a way
> around this?
Where do you see the duplicates? Do not think like a human, think what
a computer can do... There are NO duplicated entries in your output.