JCR-SQL-2 query - How do we combine results for different result types using JCR-SQL-2 query? | Community
Skip to main content
March 2, 2025
Solved

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

  • March 2, 2025
  • 3 replies
  • 757 views

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

Best answer by Aditya_Chabuku

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)

3 replies

Tethich
Community Advisor
Community Advisor
March 2, 2025

Hi @kaustubatm1 

 

Try please this version of the query:

SELECT * FROM [cq:Page] AS x UNION SELECT * FROM [nt:unstructured] AS x
SreenivasBr
Level 4
March 2, 2025
Aditya_Chabuku
Community Advisor
Aditya_ChabukuCommunity AdvisorAccepted solution
Community Advisor
March 3, 2025

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