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

Common from 4 query results

Explorer ,
Apr 25, 2009 Apr 25, 2009

Hi All,

Is there any easy way to get the common records from a dynamic number of query results. I mean I want to get like intersect in sql... the query results will be stored like recordset1,recordset2,recordset3.....

Please help!!!

TOPICS
Database access
1.2K
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
LEGEND ,
Apr 25, 2009 Apr 25, 2009

I've never tried an intersect query of queries, but this might work

<cfquery dbtype = "query">

<cfloop list = "#querylist# index = "thequery">

select id from #thequery#

intersect

</cfloop>

select id from #ListFirst(querylist)#

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
Explorer ,
Apr 26, 2009 Apr 26, 2009

Hi Dan,

I think we cant use INTERSECT for QoQ. Is there any other alternative??

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
LEGEND ,
Apr 27, 2009 Apr 27, 2009

<cfquery dbtype = "query">

select id from #querylist#

where 1 = 1

<cfloop from = "1" to = "#listlen(querylist)# - 1" index = "i">

and #listgetat(querylist, i)#.id = #listgetat(querylist, i + 1)#.id

</cfloop>

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
Explorer ,
May 04, 2009 May 04, 2009

Hi,

But this will work only if querylist have only two results sets maximum. Is there any other way if there are more than two??

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
LEGEND ,
May 04, 2009 May 04, 2009
LATEST

what happened when you tried it with more than 2 queries?

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