Expand my Community achievements bar.

SOLVED

JCR-SQL-2 query - How do we combine results for different result types using JCR-SQL-2 query?

Avatar

Level 1

I am trying to get results from 

SELECT *
FROM [cq:Page] AS s

and

SELECT *
FROM [nt:unstructured] AS t

 

Union is not working for me, any suggestions appreciated

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @KaustubaTM1 ,

 

AEM SQL2 doesnt support keyword "UNION", instead use "JOIN".

However, there should be a relation between both nodes like a parent-child, So then it will work.

I'm giving such an example for your quick referance, But if you want to deep dive & learn more. try link given above.

 

SELECT * 
FROM [cq:Page] AS p 
JOIN [nt:unstructured] AS u 
ON ISDESCENDANTNODE(u, p)
Thanks,

Aditya Chabuku

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @KaustubaTM1 

 

Try please this version of the query:

SELECT * FROM [cq:Page] AS x
UNION
SELECT * FROM [nt:unstructured] AS x

Avatar

Level 5

Avatar

Correct answer by
Community Advisor

Hi @KaustubaTM1 ,

 

AEM SQL2 doesnt support keyword "UNION", instead use "JOIN".

However, there should be a relation between both nodes like a parent-child, So then it will work.

I'm giving such an example for your quick referance, But if you want to deep dive & learn more. try link given above.

 

SELECT * 
FROM [cq:Page] AS p 
JOIN [nt:unstructured] AS u 
ON ISDESCENDANTNODE(u, p)
Thanks,

Aditya Chabuku