1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| SELECT distinct s1.id, s1.titre, s1.joueur, s1.niveau, s1.id_societe, s1.etat, s1.type, s2.nom, s2.adresse, s2.cp, s2.ville, s2.pays, s2.website, s2.etat as etat_societe, AVG(a1.note_escape) as note_escape, AVG(a1.note_ambiance) as note_ambiance, t2.path, t2.name
FROM scenario AS s1
INNER JOIN societe AS s2 ON (s1.id_societe = s2.id)
LEFT JOIN file AS f1 ON (s2.id_file=f1.id_file)
LEFT JOIN avis AS a1 ON (s1.id=a1.id_scenario)
LEFT JOIN (
SELECT i1.path, i1.name, f2.id_scenario
FROM file AS i1
INNER JOIN scenario_img AS f2 ON (i1.id_file=f2.id_file)
WHERE f2.id_scenario IN (
SELECT id
FROM scenario
WHERE scenario.id = f2.id_scenario
)
ORDER BY RAND() limit 1
) t2
ON t2.id_scenario = s1.id
GROUP BY s1.id, s1.titre, s1.joueur, s1.niveau, s1.id_societe, s1.etat, s1.type, s2.nom, s2.adresse, s2.cp, s2.ville, s2.pays, s2.website, s2.etat, t2.path, t2.name |
Partager