Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How get unique option fileds in a dynamic dropdown box

New Here ,
Apr 22, 2014 Apr 22, 2014

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

TOPICS
Advanced techniques
280
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 22, 2014 Apr 22, 2014
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources