Skip to content

Instantly share code, notes, and snippets.

@tapkain tapkain/query.sql
Created Jun 26, 2019

Embed
What would you like to do?
SELECT *
FROM (SELECT post.created_at AS post_created_at, post.id AS post_id, post.user_id AS post_user_id, post.parent_post_id AS post_parent_post_id, post.scheduled_date AS post_scheduled_date
FROM post JOIN vote ON post.id = vote.post_id JOIN content_post AS content_post_1 ON post.id = content_post_1.post_id
WHERE vote.user_id IN ('IBS7ftMAytR3HpMCtk3jzixnuIk1', '78c4CKECYWSVt3RmOIgA0U6x7Z12', 'fjHvzaoyr2OvW2SoWQeB3w5tGQB2') AND vote.vote > 15 AND post.user_id NOT IN (SELECT blocked_user.blocked_user_id AS blocked_user_blocked_user_id
FROM blocked_user
WHERE blocked_user.user_id ='snaildragon' OR blocked_user.user_id IN ('IBS7ftMAytR3HpMCtk3jzixnuIk1', '78c4CKECYWSVt3RmOIgA0U6x7Z12', 'fjHvzaoyr2OvW2SoWQeB3w5tGQB2')) AND post.parent_post_id IS NULL AND post.scheduled_date <='2019-06-19' ORDER BY post.scheduled_date DESC
LIMIT 100 OFFSET 0) AS anon_1 LEFT OUTER JOIN "user" AS user_1 ON user_1.id = anon_1.post_user_id LEFT OUTER JOIN (content_post AS content_post_2 JOIN content AS content_1 ON content_1.id = content_post_2.content_id) ON anon_1.post_id = content_post_2.post_id ORDER BY anon_1.post_scheduled_date DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.