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

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -