mysql - Join other table to get count -


i have table contains items:

items: id, body, user_id

and second table constains votes:

items_votes: id, item_id, type

i getting items simple query:

select * items 

how can votes count every item in query?

try out this...

select item.id, item.type, item.user_id, count(*) items item inner join items_votes iv on item.id = iv.item_id group item.id 

sql fiddle


Comments

Popular posts from this blog

c++ - Linked List error when inserting for the last time -

java - activate/deactivate sonar maven plugin by profile? -

java - What is the difference between String. and String.this. ? -