'AEM JCR SQL2 query to find all pages contains specific component
I wish to build a sql2 jcr query to find all pages under /content that contains this component, e.g /apps/platform/aem-core/components/content/form/form
I read https://wiki.magnolia-cms.com/display/WIKI/JCR+Query+Cheat+Sheet and tried something like below
My current attempt is something like SELECT * from [cq:Page] AS t WHERE t.contains('/apps/platform/aem-core/components/content/form/form') 
But it won't work. Please suggest me a example to find all pages contains this component. Thanks
Solution 1:[1]
As @awd has mentioned in the comments, QueryBuilder provides better capabilities. 
SQL2 however is not that bad, especially for someone with an inclination towards RDBMS ! 
The below query should fetch all the page paths using the component resourceType.
SELECT * FROM [cq:PageContent] AS s WHERE ISDESCENDANTNODE(s,'/content') AND CONTAINS(s.[sling:resourceType], 'foundation/components/text')
You've got to use square brackets for properties with namespaces in them, for e.g: cq:template, sling:resourceType, etc
Solution 2:[2]
SELECT page.* FROM [cq:Page] AS page INNER JOIN [nt:base] AS component ON ISDESCENDANTNODE(component,page) WHERE ISDESCENDANTNODE(page, '/content') AND component.[sling:resourceType] = '/apps/platform/aem-core/components/content/form/form'
Solution 3:[3]
select * from nt:base where jcr:path like '/content/%' and [sling:resourceType] ='/apps/platform/aem-core/components/content/form/form'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | SubSul | 
| Solution 2 | |
| Solution 3 | Akhil | 
