dbo.ItemTree
declare @myTemplateID uniqueidentifier = 'CCB6DC31-DB14-47E3-902D-55B2C0767A71' select t.* from dbo.Fields f inner join dbo.ItemTree t on f.ItemId = t.ID where 1=1 and FieldId = '12C33F3F-86C5-43A5-AEB4-5598CEC45116' and Value like '%' + CONVERT(varchar(100), @myTemplateID) + '%'
select distinct b.ItemPath from dbo.ItemTree a inner join dbo.ItemTree b on a.TemplateID = b.ID where 1=1 and a.ItemPath like '/sitecore/content/MySite%' order by b.ItemPath