SELECT "videos".* FROM "videos" INNER JOIN (select id from users where deleted = ?) u on u.id = videos.user_id WHERE (videos.deleted = $2);