I have 3 tables as follows
1) Tag_master
id tag_name
------------------------------
1 Movies
2 English Movies
2) Tags
Tag_id article
----------------------------------
1 ABC
2 ABC
1 XYZ
1 PQR
2 EFG
1 EFG
2 LMN
2 HIJ
--------------------------------
3)article_view
article view_date
--------------------------------
ABC 2015-07-01
ABC 2015-07-01
ABC 2015-07-02
ABC 2015-07-03
XYZ 2015-07-05
XYZ 2015-07-05
XYZ 2015-07-08
PQR 2015-08-01
PQR 2015-08-01
LMN 2015-08-02
HIJ 2015-08-02
-----------------------------------
I want to get no of viewers for each article those 'Tag' containing word Movies
My query as follow
select t.article,count(*) as cnt from tags t LEFT JOIN tag_master tm ON
t.tag_id=tm.id INNER JOIN article_view act ON t.article=act.article
WHERE tm.tag_name LIKE '%movies%' group by article
it give the following result
article cnt
----------------
ABC 8
HIJ 1
LMN 1
PQR 2
XYZ 3
-----------------
In this result article ABC have only 4 viewers but in query result it showing 8
please help me to correct the query