MySQL Forums
Forum List  »  Newbie

Re: mulitple joins not quite right?
Posted by: cris lewis
Date: August 27, 2018 04:30AM

OK, so I simplified the question and stuffed myself as I think the problem is with an additional element in the WHERE clause:

SELECT *, count(e.athID) as entries
FROM entry_meets m
left join entry_pack p on p.meetID = m.meetID
left join entry_entry e on p.packID = e.packID
where m.startdate > '2017-01-01' AND
p.status='Accepted'
group by m.meetID
order by m.startdate DESC


So the question becomes how can I get all the meets with entry counts (from entry forms that have been accepted) including meets with no entry forms?

The query returns all the meets I need (including meets with zero forms/entries) if I remove the p.status='Accepted' from the WHERE clause.

BTW, just in case if confuses people an entry form is actually known as an entry pack in the system for historic reasons.

Thanks again.

Options: ReplyQuote


Subject
Written By
Posted
Re: mulitple joins not quite right?
August 27, 2018 04:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.