markshen2004
Programmer
I have a question about joining table and using count() at same time.the sql below do not work .
I want to get a series list and list how many product in each series.but it do not work.do you think if using stored procedure can fix it?
Please let me now how to fix it.Thank you for your help.
1 sql statement
SELECT Series.*,count(Products.product_id)
FROM Series,Products
WHERE Series.series_id=Products.series_id
GROUP BY Products.series_id
ORDER BY Products.sort_order
2 the table structure like this
Series
serial_id name is_deleted
1 s1 0
2 s2 0
3 s3 0
Products
product_id name serial_id sort_order is_deleted
1 p1 2 1 0
2 p2 3 2 0
3 p3 3 3 0
4 p4 2 4 0
5 p5 2 5 0
I want to get a series list and list how many product in each series.but it do not work.do you think if using stored procedure can fix it?
Please let me now how to fix it.Thank you for your help.
1 sql statement
SELECT Series.*,count(Products.product_id)
FROM Series,Products
WHERE Series.series_id=Products.series_id
GROUP BY Products.series_id
ORDER BY Products.sort_order
2 the table structure like this
Series
serial_id name is_deleted
1 s1 0
2 s2 0
3 s3 0
Products
product_id name serial_id sort_order is_deleted
1 p1 2 1 0
2 p2 3 2 0
3 p3 3 3 0
4 p4 2 4 0
5 p5 2 5 0