質問があります:
SELECT count(authors.id), country.name from authors
INNER JOIN articles ON authors.article_id = articles.id
INNER JOIN author_affi_rel ON authors.id = author_affi_rel.id_author
INNER JOIN affiliations ON author_affi_rel.id_affiliation = affiliations.id
INNER JOIN country ON affiliations.country = country.unique_id
WHERE articles.journal_id = 20 AND authors.correspondence =1
GROUP BY country.name
ORDER BY count(authors.id) DESC
ここで、国ごとの著者の数を選択しています。
テーブル author_affi_rel では、著者ごとに複数の所属を持つことができることを除いて、すべて正常に機能するため、私の結果では著者が 2 倍になります。
私の目標は、
INNER JOIN author_affi_rel ON authors.id = author_affi_rel.id_author
私はやろうとしました:
INNER JOIN author_affi_rel ON authors.id = (SELECT id_author FROM author_affi_rel WHERE id_author = authors.id LIMIT 1)
しかし、私のクエリはそこにストックされていますが、応答はありません。
内部結合を実行し、結果を 1 つだけに制限する方法を知っているでしょうか。
よろしくお願いします。