Search posts with a specific post type ID

1

Please login or register to vote for this query.

(click on this box to dismiss)

For searching tag wikis, mainly. If a post link doesn't work, try the revisions link. 1=question, 2=answer, 3=orphaned tag wiki, 4=tag wiki excerpt, 5=tag wiki, 6=moderator nomination, 7=election description, 8=privilege wiki

Science Fiction and Fantasy

Q&A for science fiction and fantasy enthusiasts

select p.Id as [Post Link],
    'site://posts/' + cast(p.Id as nvarchar) + '/revisions|Post revisions' as [Revisions],
    t.TagName,
    (case when p.OwnerUserId is not null then
      'site://users/' + cast(p.OwnerUserId as nvarchar) + '|' else '' end) +
      coalesce(p.OwnerDisplayName, u.DisplayName) as [User Link],
    pt.Name as [Post Type],
    p.CreationDate,
    p.Body
from Posts p
left join Users u on p.OwnerUserId = u.Id
left join PostTypes pt on p.PostTypeId = pt.Id
left join Tags t on t.ExcerptPostId = p.Id or t.WikiPostId = p.Id
where PostTypeId in (##PostTypeId?4, 5##)
    and lower(p.Body) like '%' + lower(##text:string##) + '%'
    -- exclude orphaned tag wikis with PostTypeId 4 or 5:
    and (PostTypeId not in (4, 5) or t.TagName is not null)
order by p.Score desc, p.CreationDate desc

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results