• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to count the number of 02 tables

#1
Hi every body ?
I have 2 table data:
db_category: 

+idcate
+name
db_book:
+ idbook
+ name
+ idcate

Now I want to count the number by category. 

Example: 
Book 1: 2 file
Book 2: 5 file

Please help me, thanks Big Grin
Reply

#2
This makes no sense at all. Huh

example
Code:
SELECT
    category.name,
    count(book.id)
FROM
    category
INNER JOIN
    book
ON category.id = book.id
GROUP BY category.id

cat_a 12
cat_b 10
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.