- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI have two queries; the first one simply returns a list (of, say, all letters of the alphabet) and the second returns a varying number of letters. What I want to do is print out the results of the first query highlighting the ones that are contained in the second query. I'm guessing it would be done something like the following:
<cfloop query="qAlphabet">
<cfif [qSelectLetters contains qAlphabet.letter]><b></cfi
#qAlphabet.letter#
<cfif [qSelectLetters contains qAlphabet.letter]></b><cfi
<br/>
</cfloop>
But I'm unsure of how to phrase the part in the brackets. I've done it by setting a string (looping through query 2, to give something like "a,c,g,w" and seeing if that string contains qAlphabet.letter, but it seems like that would be excessively huge if the queries were involving blocks of text, not just letters.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: danrosenthalPosted on 2008-10-02 at 15:12:48ID: 22629267
The syntax for your example would be something along the lines of:
et.letter) ,qSelectLe tters)>
<cfif LISTFIND(valuelist(qAlphab
But, you are correct in that it wouldn't be wise to use that solution for larger resultsets.
I would recommend doing the comparing at the SQL level. Either in the original query using a LEFT JOIN, or by using a query of queries.
Rough example of how you would use a LEFT JOIN to acheive the desired result:
SELECT
a.value
, CASE WHEN b.joinID IS NOT NULL THEN 1 ELSE 0 END as isrecordfound
FROM allrecordtable a
LEFT JOIN myvaluetable b
ON a.joinID = b.joinID
And your CFIF inside the output loop would be simply:
<cfif isrecordfound eq 1>