Skip to content
Advertisement

MySQL query to get total item number from table 2 to owner in table 1?

I got 2 tables: Owners and Storage as below:

Table: owners

JavaScript

Table: Storage

JavaScript

Question: Is there a query to get how many fruit in each owner’s box in result? Like:

JavaScript

I tried to join 2 tables but it return me hundreds of records that duplicated. Much appreciated if anyone could guide me out.

Advertisement

Answer

JavaScript

fiddle

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement