diff --git a/functions/article_functions.php b/functions/article_functions.php index 44c2d09..b7256a5 100644 --- a/functions/article_functions.php +++ b/functions/article_functions.php @@ -16,7 +16,7 @@ function article_ids_by_recency() function articles_ids_by_author($author_id) { - $query = 'SELECT article_id FROM article ORDER BY published_at DESC WHERE author_id = ' . $author_id . ';'; + $query = 'SELECT article_id FROM article WHERE author_id = ' . $author_id . ' ORDER BY published_at DESC;'; $results = query_one_or_more_results($query); $ids = []; @@ -41,7 +41,7 @@ function article_tags() function article_ids_by_tag($tag_id) { - $query = 'SELECT article_id FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE tag = "' . $tag_id . '";'; + $query = 'SELECT article_id FROM article WHERE article.article_id IN ( SELECT article_tags.article_id FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE tag = "' . $tag_id . '") ORDER BY published_at DESC;'; $results = query_one_or_more_results($query); $ids = [];