All pastes #46892 Raw Edit

Something

public text v1 · immutable
#46892 ·published 2006-03-24 23:38 UTC
rendered paste body
SELECT DISTINCT ON (post.id) count(post.id) AS count
     FROM list_posts AS post
     LEFT OUTER JOIN private ON (post.id = private.pid)
     LEFT OUTER JOIN official_user AS adminu ON (adminu.user = adminu.user)
     LEFT OUTER JOIN count_comments AS ccount ON (post.id = ccount.pid)
        WHERE
		   adminu.user = %s            --User is the official_user  
		   OR 
           (post.private = false            --Post is not private
           OR private.uid  = %s            --User is allowed to view post
	   )