SELECT beers.*, breweries.name AS "brewery", breweries.url AS "brewery_url", breweries.alias AS "brewery_alias", beers_styles.name AS "style" FROM beers INNER JOIN breweries ON beers.brew_id = breweries.id INNER JOIN beers_styles ON beers_styles.id = beers.style_id ORDER BY beers.photo DESC, beers.id DESC LIMIT 400, 40