Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql count total by foreign key

SELECT books.*, count(orders.book_id) as number_of_orders        
from books
left join orders
on (books.book_id = orders.book_id)
group by
    books.book_id
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sql #count #total #foreign #key
ADD COMMENT
Topic
Name
1+3 =