I have a complicated SQL expression problem (at least for me). I will really appreciate if someone take me out of my problem.
Now to the point:
My appliction is about travel agencies, posting offers in some categories. I have 3 tables:
I have `jour_offers`.agencyID related to `jour_agency`.ID
and `jour_offers`.categoryID related to `jour_categories`.ID
My agency wants to see all the `jour_categories` and how many offers it has in every one of them.
This is what I did...
...and I get a list of all categories with counting all posted offers. But when I try to count only offers posted by the specific agency (WHERE jour_offers.agencyID = 2) it returns only categories where there are 1 or more offers.Code:SELECT jour_categories.ID, jour_categories.name, COUNT( jour_offers.ID ) AS COUNT_OF_OFFERS FROM jour_categories LEFT JOIN jour_offers ON (jour_categories.ID = jour_offers.categoryID) GROUP BY jour_categories.ID
If anybody can help me... it will be great! Thanks in advance!
See the databases in the attached .JPG