PLEASE HELP FOR SIMPLE QUERY!!!

PLEASE HELP FOR SIMPLE QUERY!!!

am 24.01.2006 18:21:07 von sonofuori

Hi to all....

I need a problem with query.... Mysql Rel 3.23.58...

2 Table...

is table1
1) id - description - other1 - other 2

id table2
2) id - table1_id - date - price

In first table there is articles in table2 there are more date and
price for table1 articles...


Query:
i need a list of ALL articles in table_1 with sum of table2 date of
that article...

SELECT table1.id, table1.description, count(table2.id) FROM table1,
table2 WHERE table1.id=table2.table1_id GROUP BY table1.id


Yes...all OK but.. i don't SEE Empty table1 product sigh sigh... i need
to see also empty table1 article....



anyone have idea ??

for me the solution is simple.... but i don't found ... sigh sigh! :-)

....if you resolve me questions i offer you Italian Lunch hehehe

Thanks
Roby - italy

Re: PLEASE HELP FOR SIMPLE QUERY!!!

am 24.01.2006 19:52:46 von Bill Karwin

wrote in message
news:1138123267.544786.188740@f14g2000cwb.googlegroups.com.. .
> SELECT table1.id, table1.description, count(table2.id) FROM table1,
> table2 WHERE table1.id=table2.table1_id GROUP BY table1.id
>
> Yes...all OK but.. i don't SEE Empty table1 product sigh sigh... i need
> to see also empty table1 article....

Very difficult to understand the question. Sounds like you need to use an
outer join:

SELECT table1.id, table1.description, COUNT(table2.id)
FROM table1 LEFT OUTER JOIN table2 ON table1.id = table2.table1_id
GROUP BY table1.id

Regards,
Bill K.