Skip to main content
New Member
Mar 2, 2025 11:07 AM UTC
Solved

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

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

Aditya_Chabuku
Aditya_ChabukuAccepted solution
Community Advisor
Mar 3, 2025 8:33 AM UTC

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

3 replies

Tethich
Community Advisor
Community Advisor
Mar 2, 2025 12:14 PM UTC

Hi @kaustubatm1 

 

Try please this version of the query:

SELECT * FROM [cq:Page] AS x UNION SELECT * FROM [nt:unstructured] AS x
Translate
SreenivasBr
Level 4
Mar 2, 2025 9:23 PM UTC
Aditya_Chabuku
Community Advisor
Aditya_ChabukuCommunity AdvisorAccepted solution
Community Advisor
Mar 3, 2025 8:33 AM UTC

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)
Translate
Thanks,Aditya Chabuku