Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles
SET NOCOUNT ON DECLARE @Question TABLE ( Id int, PostTypeId tinyint, ParentId int, Body nvarchar(max), Title nvarchar(250), Tags nvarchar(250), CreationDate datetime ) DECLARE @Answer TABLE ( Id int, PostTypeId tinyint, ParentId int, Body nvarchar(max), Title nvarchar(250), Tags nvarchar(250), CreationDate datetime ) INSERT @Question SELECT TOP 50000 Id, PostTypeId, ParentId, Body, Title, Tags, CreationDate FROM Posts WHERE tags like '%<##tag?python##>%' and PostTypeId = 1 and CreationDate >= '2020-06-01 00:00:00' and CreationDate < '2020-07-01 00:00:00' INSERT @Answer SELECT p.Id, p.PostTypeId, p.ParentId, p.Body, p.Title, p.Tags, p.CreationDate FROM Posts p, @Question q WHERE p.PostTypeId = 2 and p.ParentId = q.Id SET NOCOUNT OFF SELECT p.* FROM ( SELECT * FROM @Question UNION SELECT * FROM @Answer ) AS p