Skip to main content
Participant
April 22, 2014
Question

How get unique option fileds in a dynamic dropdown box

  • April 22, 2014
  • 1 reply
  • 303 views

I'm trying to get single select options in a dropdown menu.

The data is coming from two database.

My CFQuery looks like


<cfquery name="related" datasource="ISSUE">
SELECT sparprod
FROM Related
where Active = 'Yes'
union all
select sparprod from TBL_issue
WHERE issue_number = <cfqueryparam value="#URL.issue_number#" cfsqltype="cf_sql_numeric">
ORDER BY sparprod ASC
</cfquery>

  <td>

        <select name="sparprod" id="sparprod" >

          <cfoutput query="related">

            <option value="#related.sparprod#" <cfif (isDefined("rs_issue.sparprod") AND related.sparprod EQ rs_issue.sparprod)>selected="selected"</cfif>>#related.sparprod#</option>

          </cfoutput>

        </select>

And the output in the dropdown box looks like

PRODUCTS

SPARES

SPARES

HOW can i have only ONE TIME Spares.

I've got this problem with all my dynamic dropdown boxes.

Thanks

For your help in advance

Klaas

This topic has been closed for replies.

1 reply

Carl Von Stetten
Legend
April 22, 2014

Assuming "SPARES" doesn't appear twice in the Related table, UNION ALL may be adding a redundant "SPARES" record from the TBL_issue table.  Try using UNION instead.  If there are duplicates within either or both tables, try using SELECT DISTINCT in one or both places.

-Carl V.