I am learning to use mysql.So, I got some problems.
I have three table :users movie and movie watching history(moviewh)
the structure of movie table is:
movie_id[key] movie_title
and users is:
user_id[key] user_name
and moviewh is:
user_id[key] movie_id[key] watching_date[key]
and my sql query is:
EXPLAIN
SELECT m.movie_id,m.movie_name_cn FROM movie AS m
LEFT JOIN moviewh AS mwh
ON m.movie_id = mwh.movie_id
WHERE date_format(mwh.watching_date,'%Y-%m-%d') = '2010-11-01' AND mwh.user_id = 1

so . how can I optimize the table and query ??
Why are you doing a left join if you are only interested in seeing what movies a user has watched on a particular date?
assuming of course that a user can’t have watched movies that don’t exist in your db …