Show a list of books that have more than one author?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
36 views
There are 3 tables books, m2m_books_authors(for communication many-to-many), authors.
In the books there is a field b_id, b_name.
In m2m_books_authors fields b_id, a_id.
Authors in the fields a_id, a_name.
I'm doing a query with a join:
SELECT b_name, a_name from books join m2m_books_authors using(b_id) join authors using(a_id)

What to add to have chosen only those books with more than 1 author?
by | 36 views

1 Answer

0 like 0 dislike
It turned out this solution:
SELECT b_name, count(a_id) as how_much from books join m2m_books_authors using(b_id) join authors using(a_id) group by b_id having how_much >1
by

Related questions

0 like 0 dislike
6 answers
asked Mar 23, 2019 by vanuch
0 like 0 dislike
5 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,082 users