Post info

1

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A for administrators, end users, developers and designers for Craft CMS

Declare @PostId int = ##PostID?150005## --7933

Select 
  OwnerUserId as [User Link], 
  Case when PostTypeId = 1 Then 'Question' Else 'Answer' End as 'Type',
  Null as [Comment Link], 
  Body as Comment, 
  Id as [Post Link], 
  CreationDate
From Posts
Where Id = @PostId

Union

Select 
  UserId as [User Link], 
  'Comment' as 'Type',
  Id as [Comment Link], 
  Text as Comment, 
  Null as [Post Link], 
  CreationDate
From Comments
Where PostId = @PostId

Union

Select 
  OwnerUserId as [User Link],
  Case when PostTypeId = 1 Then 'Question' Else 'Answer' End as 'Type',
  Null as [Comment Link], 
  Body as Comment, 
  Id as [Post Link], 
  CreationDate
From Posts
Where ParentId = @PostId

Order by CreationDate Asc

Enter Parameters

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