sql - Get all entries from one table together with the count of these entries in another table -


I have 3 tables:

  • The user (id, name, ... < / Li>
  • Item (id, name, ...)
  • download (user_id, item_id, ...)

How do I get all the users With the number of downloads they have?

How do I get all the users together With the number of downloads?

Use:

  SELECT u.name, COUNT (d.user_id) users 'num_downloaded' and download the OIN S on d.user_id = u.user_id GROUP by u.name  

If you want to see how many times a user has downloaded a particular item:

Select username 'user_name', name 'item_name', COUNT (DUGEER_ID), and download the user from 'UN downloads'. D.user_id = u.user_id iitit_id = d on iits Add the .item_id group to U.Name, i.name

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -