i have USERS TABLE that contains the following fields _id name number_of_posts
and i have POSTS TABLE that contains the following fields _id user_id post_text
no the relationship between the users and posts is one- to -many i.e one user have many post
the question is how to update the number_of_posts in users table such that it will hold the number of post in the posts table
UPDATE
I have these tables filled with about hundreds of records there is no way to use the trigger to update the number_of_posts .
You can do this with a trigger on the posts table. Every time a post is inserted, update the number_of_posts on the users table.
See http://dev.mysql.com/doc/refman/5.6/en/triggers.html
Update: full worked solution