列t.name(流派)显示许多相同的值我试图让它工作但我没有成功..
这是我的SQL
select o.id, b.title, a.firstName, a.lastName,
b.noOfPages, b.price, group_concat(t.name) as 'genre'
from author a,book_author ba, book_type bt,orders o,type t, book b, order_list ol
where ol.book_fk = b.id
and bt.book_fk = b.id
and bt.type_fk = t.id
and ba.author_fk = a.id
and ba.book_fk = b.id
and ol.orders_fk = '74'
GROUP BY ol.id
图片用于显示列类型查询返回的值数
答案 0 :(得分:1)
我相信你关注你的类型专栏中“犯罪”的重复价值。 尝试在group_concat中使用distinct。
select o.id, b.title, a.firstName, a.lastName,b.noOfPages, b.price,
group_concat(distinct t.name) as 'genre' from author a,book_author ba,
book_type bt,orders o,type t, book b, order_list ol where ol.book_fk = b.id
and bt.book_fk = b.id and bt.type_fk = t.id and ba.author_fk = a.id
and ba.book_fk = b.id and ol.orders_fk = '74' GROUP BY ol.id;