Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
now i was using 8 category in the table..

each category include a many product.....


how to count a product in sql...


i was using 2 table a categorytable and product table

for example

category

tomoto(5)
orange(8)
apple(4)


please anybody help me in sql query
Posted
Updated 22-Jan-16 23:14pm
v2

1 solution

Without knowing your exact table definitions, and sample data, we can't give you an exact answer.
But it's probably along the lines of
SQL
SELECT p.Name, Count(c.ID) FROM Products p
JOIN Categories c
ON p.CategoryID = c.ID
GROUP BY p.Name
 
Share this answer
 
Comments
MohamedEliyas 23-Jan-16 6:19am    
i got correct output thanks
OriginalGriff 23-Jan-16 6:28am    
You're welcome!
MohamedEliyas 25-Jan-16 0:06am    
hi sir. i am a new web developer how to easily write sql query. pls guide to me?
OriginalGriff 25-Jan-16 3:10am    
There are a lot of tutorials on the web, but probably the definitive place is W3Schools:
http://www.w3schools.com/sql/
There are "brick wall" moments, but it covers the basics early and it is always accurate.
There are also whole books just devoted to SQL:
https://www.google.co.uk/search?q=SQL+books&oq=SQL+books&aqs=chrome..69i57j0l5.3406j0j4&sourceid=chrome&es_sm=93&ie=UTF-8
Which are worth looking out for.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900