superninja
superninja

Reputation: 3401

Query All Pages Based on Compoent's Resource Type

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?

Upvotes: 2

Views: 782

Answers (1)

Plàcid Masvidal
Plàcid Masvidal

Reputation: 140

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"

Upvotes: 1

Related Questions