Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to Select Multiple Fields in JCR-SQL2 Query?

Avatar

Level 3

How to select multiple fields in a JCR-SQL2 query like such:

 

SELECT page.[jcr:created], page.[jcr:createdBy], page.[jcr:primaryType] FROM [cq:Page] AS page
INNER JOIN [nt:base] AS component ON ISDESCENDANTNODE(component, page)
WHERE component.[sling:resourceType] = '/libs/fd/af/components/aemform'
AND ISDESCENDANTNODE(page, '/content') 

 

 

Currently it is only returning page relative paths, despite I have selected 3 fields in the query: page.[jcr:created], page.[jcr:createdBy], page.[jcr:primaryType].


 
wenwang1_0-1683754208805.png

 

 

 

Am I missing something here? Thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Here's a query you can use. 

Find me all cq:PageContent nodes, where properties exists: jcr:created, jcr:createdBy, jcr:primaryType

and it must be nodes under the paths of /libs/fd/af/components/aemform or /content

 

SELECT page.* FROM [cq:PageContent] AS page 
WHERE page.[jcr:created] IS NOT NULL 
   AND page.[jcr:createdBy] IS NOT NULL 
   AND page.[jcr:primaryType] IS NOT NULL 
   AND (ISDESCENDANTNODE(page,'/libs/fd/af/components/aemform') OR ISDESCENDANTNODE(page,'/content'))

 

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Here's a query you can use. 

Find me all cq:PageContent nodes, where properties exists: jcr:created, jcr:createdBy, jcr:primaryType

and it must be nodes under the paths of /libs/fd/af/components/aemform or /content

 

SELECT page.* FROM [cq:PageContent] AS page 
WHERE page.[jcr:created] IS NOT NULL 
   AND page.[jcr:createdBy] IS NOT NULL 
   AND page.[jcr:primaryType] IS NOT NULL 
   AND (ISDESCENDANTNODE(page,'/libs/fd/af/components/aemform') OR ISDESCENDANTNODE(page,'/content'))