Query All Pages Based on Compoent's Resource Type

511 views Asked by At

I have this JCR-SQL2 query to get all pages that have a specific component:

SELECT page.* FROM [cq:Page] AS page INNER JOIN [nt:base] AS component ON ISCHILDNODE(component,page) WHERE component.[sling:resourceType] ='/libs/wcm/foundation/components/image' AND page.[jcr:path] LIKE '/content'

It compiles properly but no results were returned. I also tried to change the component resource type but nothing got returned when it should. I was wondering if there's anything wrong with my query?

1

There are 1 answers

0
Plàcid Masvidal On BEST ANSWER

This should work:

SELECT page.* FROM [cq:Page] AS page INNER JOIN [nt:base] AS component 
ON ISDESCENDANTNODE(component, page) 
WHERE ISDESCENDANTNODE(page, "/search/in/path") 
AND component.[sling:resourceType] = "/resource/path"