mysql - Getting an item count and joining table to display items customer detail -
i have 2 tables: customers items
i need display query shows each customers (selling) items total
example:
customer_name | total_items_customer_selling | customer_address
i have used count() keep getting total value items in table
select count(id) items group items.id
also how join ? hope that's specific enough
structure:
customers(id(primary), name, address, city, state).
items(id(primary), description, cost, seller(fk))
hope explains structure better
select c.id, c.name, count(*) items customers c left join items on i.seller = c.id group c.id, c.name
Comments
Post a Comment