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?
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"