0
Helo everyone。在第二个表格中随机选择3条记录
我是一名MySQL初学者,所以我需要一些帮助。 目前,我的请求返回了系列(ID,名称,说明)的信息和该请求的系列备注的平均值。
SELECT s.* , round(coalesce(avg(note.note) , 0) , 1) AS average
FROM serie AS s
LEFT JOIN note ON s.id_serie = note.id_serie
GROUP BY s.id_serie
ORDER BY average DESC
,我有这种反应
id_serie name annee description average
1 DBZ 1984 test 3.5
2 Bleach 2001 description2 2.0
我还有一个表中的内容意甲的风格。该表只有id_genre和id_serie。
我现在想要的是一个查询所有数据的请求,我已经拥有一个系列的+ max 3 id_genre。
id_serie name annee description average genre1 genre2 genre3
1 DBZ 1984 test 3.5 1 2 9
2 Bleach 2001 description2 2.0 1 NULL NULL
如果可能的话,我想也该类型是随机选择,如果意甲有3个以上流派(永不选择2次同类型的系列)