This commit is contained in:
Jason Streifling 2024-12-27 07:20:24 +01:00
parent 8d41caf40a
commit 0a14545a19
3 changed files with 6 additions and 6 deletions

View File

@ -43,8 +43,8 @@ func (db *DB) GetArticleAuthors(c *Config, articleID int64) ([]*User, error) {
query := ` query := `
SELECT u.id SELECT u.id
FROM articles a FROM articles a
INNER JOIN articles_tags at ON a.id = at.article_id INNER JOIN articles_authors aa ON a.id = aa.article_id
INNER JOIN users u ON at.author_id = u.id INNER JOIN users u ON aa.author_id = u.id
WHERE a.id = ? WHERE a.id = ?
` `
rows, err := db.Query(query, articleID) rows, err := db.Query(query, articleID)

View File

@ -43,8 +43,8 @@ func (db *DB) GetArticleContributors(c *Config, articleID int64) ([]*User, error
query := ` query := `
SELECT u.id SELECT u.id
FROM articles a FROM articles a
INNER JOIN articles_tags at ON a.id = at.article_id INNER JOIN articles_contributors ac ON a.id = ac.article_id
INNER JOIN users u ON at.contributor_id = u.id INNER JOIN users u ON ac.contributor_id = u.id
WHERE a.id = ? WHERE a.id = ?
` `
rows, err := db.Query(query, articleID) rows, err := db.Query(query, articleID)

View File

@ -43,8 +43,8 @@ func (db *DB) GetArticleTags(articleID int64) ([]*Tag, error) {
query := ` query := `
SELECT t.id, t.name SELECT t.id, t.name
FROM articles a FROM articles a
INNER JOIN articles_tags at ON a.id = at.article_id INNER JOIN articles_tags at ON a.id = at.article_id
INNER JOIN tags t ON at.tag_id = t.id INNER JOIN tags t ON at.tag_id = t.id
WHERE a.id = ? WHERE a.id = ?
` `
rows, err := db.Query(query, articleID) rows, err := db.Query(query, articleID)