Re: EuSQL

new topic     » goto parent     » topic index » view thread      » older message » newer message

Alex Chamberlain wrote:
> 
> Alex Chamberlain wrote:
> > I found the Solution:
> > 
> > SELECT CATEGORIES.ID, CATEGORIES.NAME, CATEGORIES.DEFAULT_PRICE,
> > COUNT(PRODUCTS.CAT_ID)
> > FROM CATEGORIES INNER JOIN PRODUCTS ON CATEGORIES.ID = PRODUCTS.CAT_ID GROUP
> > BY CATEGORIES.ID, CATEGORIES.NAME, CATEGORIES.DEFAULT_PRICE;
> > 
> 
> Actually, it only shows the categories that actually have a product in.
> Problem!?!

This is what outer (a LEFT JOIN, in this case) joins are for:

SELECT CATEGORIES.ID, CATEGORIES.NAME, CATEGORIES.DEFAULT_PRICE,
COUNT(PRODUCTS.CAT_ID)
FROM CATEGORIES LEFT JOIN PRODUCTS ON CATEGORIES.ID = PRODUCTS.CAT_ID 
GROUP BY CATEGORIES.ID, CATEGORIES.NAME, CATEGORIES.DEFAULT_PRICE;

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu