Solved

Compare two value lists and find ANY matches

Posted on 2006-06-22
3
206 Views
Last Modified: 2013-12-24
What is the best way to compare two value lists and return TRUE if  ANY matches are found.  For instance...

Value List #1 = Item1, Item3, Item5, Item7
Value List #2 = Item2, Item3, Item4

should return TRUE since Item3 in in both lists.

Thanks.
0
Comment
Question by:SiriusPhil
  • 2
3 Comments
 
LVL 7

Expert Comment

by:aseusainc
Comment Utility
<cfset List1 = "Item1,Item3,Item5,Item7">
<cfset List2 = "Item2,Item3,Item4">

<cfset match = 0>
<cfloop list = #list2# index = x>
<cfif listcontains(#list1#,#x#)>
  <cfset match = 1>
</cfif>
</cfloop>

<cfoutput>#match#</cfoutput>

0=no match, 1=match
0
 
LVL 7

Accepted Solution

by:
aseusainc earned 500 total points
Comment Utility
This may be better actually (use listfind instead of listcontains..my bad):

<cfset List1 = "Item1,Item3,Item5,Item7">
<cfset List2 = "Item2,Item3,Item4">

<cfset match = 0>
<cfloop list = #list2# index = x>
<cfif listfind(#list1#,#x#)>
  <cfset match = 1>
</cfif>
</cfloop>

<cfoutput>#match#</cfoutput>

0=no match, 1=match
0
 

Author Comment

by:SiriusPhil
Comment Utility
Awsome.  Thanks.  I think I was just over engineering it.

Phil
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now