max bugaenko
max bugaenko

Reputation: 159

how to such a mysql join

i have such tables:

movie: id, user, title

thank: id, user, movie

what i need is to get count of thanks made TO specific user.

Upvotes: 0

Views: 45

Answers (2)

yitwail
yitwail

Reputation: 2009

how about

SELECT COUNT(*) FROM thank WHERE user='specific user';

Upvotes: 1

Harry Joy
Harry Joy

Reputation: 59660

may be by

select count(*) from `thank` t join `movie` m on t.user=m.user 
  where m.user='<specific_usr>';

or if both have same field then why don't simply use

 select count(*) from `thank` where user='<specific_usr>';

or if you want count for all user then try:

 select user,count(*) from `thank` group by user;

Upvotes: 1

Related Questions