Show all (my, their, everyone's) uploads

(Régis Hanol) #21

Just a tip, when you are joining tables, it is more readable to use the “JOIN ... ON” syntax

   SELECT CONCAT('<a href = "/p/',, '">', topics.title) AS html$post
        , CONCAT('<img src="', url, E'" style = "max-width: 100%\x3B">') AS html$Image
     FROM post_uploads
     JOIN uploads ON = post_uploads.upload_id
     JOIN posts   ON   = post_uploads.post_id
     JOIN topics  ON  = posts.topic_id
    WHERE DATE(current_date) - DATE(uploads.created_at) < 7   
      AND topics.archetype = 'regular'
 ORDER BY uploads.created_at DESC

That way, you’re making it clear that you’re joining several tables and what columns you used.