Posts w/imgur links, optionally excluding those favorited by Flagston sock or with CACTUS links

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Flagston sock is here: https://chemistry.stackexchange.com/users/36917/flagston
-- No nefarious activities intended! Favorites seem pretty innocuous....

-- IncludeFlagged: Include posts favorited by Flagston (Y/N)?
-- IncludeCactus: Include posts containing NIH CACTUS links (Y/N)?
DECLARE @IncludeFlagged nvarchar = ##IncludeFlagged:string?N##
DECLARE @IncludeCactus nvarchar = ##IncludeCactus:string?N##
DECLARE @FlagstonID int = 36917

SET @IncludeFlagged = UPPER(@IncludeFlagged)
SET @IncludeCactus = UPPER(@IncludeCactus)

SELECT p.Id AS [Post Link], p.Score, p.CreationDate

FROM Posts p
LEFT JOIN Votes v ON (p.Id = v.PostId OR p.ParentId = v.PostId)
                    AND v.VoteTypeId = 5 AND v.UserId = @FlagstonID

WHERE CHARINDEX('i.stack.imgur.com', LOWER(p.Body)) > 0 AND
      (v.Id IS NULL OR @IncludeFlagged = 'Y') AND
      (CHARINDEX('cactus.nci.nih.gov', LOWER(p.Body)) = 0 OR @IncludeCactus = 'Y')

ORDER BY p.CreationDate ASC

Enter Parameters

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