Count how many users got more then 500 images from two different tables
13:49 08 Feb 2021

I am trying to make a simple join query.

For that I have two tables:

  1. First table albums with column name album_id, user_id* and album_img_count (album_img_count - column shows how many images belong to an album.).

  2. Second table is users with column name user_id*.

*user_id are the same for both tables (albums.user_id=users.user_id)

I want to count how many users got more then 500 images total.

Tricky part - user can have 1 album with 600 images, or 700 albums with 1 image. And both would be valid for our query. Therefore we can't simply count album_id or album_img_count we have to somehow combine them.

sql join mariadb