2

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?

superninja
  • 3,114
  • 7
  • 30
  • 63

1 Answers1

1

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"
Plàcid Masvidal
  • 130
  • 1
  • 2
  • 12