All pastes #46895 Raw Edit

Anonymous

public text v1 · immutable
#46895 ·published 2006-03-25 00:34 UTC
rendered paste body
'SELECT DISTINCT ON (post.id) * 
     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
					 )
     ORDER BY post.id desc