Combining Queries and combination permutations

Newbie here,

Have two queries and they each work independently and I would like to combine them to feed the results of the first into the second.
The first generates two sets patents based on companies and some additional conditions.

MATCH (a1:company{name:'A1'})-[:Assigned_to]-(a:patent)-[:Cites{who:'examiner'}]->(b:patent)-[:Assigned_to]-(a2:company{name:'A2'})WHERE toInteger(a.num)>9000000 AND toInteger(b.num)>8000000
RETURN a1,a2,a,b

Separately I have query that gets the path between two patents

MATCH p=(pat1)-[:Classified_as]->(b:cpc)-[:Reports_to*..]->(e:cpc)<-[:Reports_to*..]-(c:cpc)<-[:Classified_as]-(pat2)
RETURN pat1,pat2,p

I would like to feed the two sets of patent nodes into the second query and generate all the permutations and resulting paths. The intent is to use the 'a' nodes of the first query as pat1 and the 'b' as pat2 in their various combinations.
How would I go about combining the two queries?
Andy

Hello @andy.hegedus :slight_smile:

Did you have a look at WITH?
There are also APOC procedures to run Cypher fragments for each rows.

Regards,
Cobra