I have two queries:
SELECT
s.id AS id,
g.id AS group_id,
g.nazwa AS group_name,
s.nazwa AS station_name,
s.szerokosc AS szerokosc,
s.dlugosc AS dlugosc,
s.95 as p95,
s.98 as p98,
s.Diesel as diesel,
s.DieselTIR as dieseltir,
s.Super98 as s98,
s.SuperDiesel as sdiesel,
s.LPG as lpg,
s.ulica as ulica,
s.kodPocztowy as kod_pocztowy,
s.miasto as miasto,
w.id as wojewodztwo_id,
w.nazwa as wojewodzto_nazwa,
k.id as kraj_id,
k.kod as kraj_kod,
k.nazwa as kraj_nazwa,
s.data as date_mod,
s.active as active
FROM stacje_main s
JOIN stacje_grups g ON (s.grupa=g.id)
JOIN wojewodztwa w ON (s.wojewodztwo=w.id)
JOIN kraje k ON (w.kraj=k.id)
WHERE s.data > 0;
and
SELECT
AVG(rr.vote) as avarge,
COUNT(rr.station_id) counter
FROM stacje_ratings rr
GROUP BY rr.station_id;
and in second querry not all id (station_id) are present, and sometimes are doubled. there is need to join station_id with id, and give average value of rate for each id.
The problem that when no rate, the value in question in average and counter have to be 0.
When i combined this queries i see only this ID, that has present station_id. But i want to see all.