I am trying to write a query that connects 3 tables.
The first table is info about each festival. The second table is the number of votes for each festival. The third table is reviews for each festival.
I want to join all 3 tables so I get all the columns from table1, join table1 with table2 on the festivalid, but I also need to count the number of records in table 3 that apply to each festival.
The first 2 tables give me a result because they both have data in them but table 3 is empty because there are no reviews yet so adding that to my query gives me no results.
SELECT f.*,
v.total,
v.votes,
v.festivalid,
r.reviewcount as count
FROM festivals f
INNER
JOIN vote v
ON f.festivalid = v.festivalid
INNER
JOIN (SELECT festivalid,
count(*) as reviewcount
FROM reviews)
GROUP BY festivalid) as r
on r.festivalid = v.festivalid