i have 3 tables like this
questions_table
question_id | content | user |
1 | my first question | userOne@email.com |
2 | my second question | userTwo@email.com|
replies_table
reply_id | question_id|user |content |voteCount|
1 | 1 |userSeven@email.com |first reply question 1 |0 |
2 | 1 |userEight@email.com |second reply question1 |0 |
vote_table
vote_id | reply_id| voted_by |
1 | 2 | userThree@email.com|
2 | 2 | userFour@email.com |
so to explain this:
- A question was posted by two users
userOne@email.com
andUserTwo@email.com
- Then
userSeven@email.com
anduserEight@email.com
replied to question 1. - Then the reply of
userEight@email.com
which has areply_id
of2
was voted up byuserThree@email.com
anduserFour@email.com
what i need to do is to write an event scheduler in myphpmyadmin which will run every 2 hours.
what i want the query to do is to update the column voteCount
in replies_table
by counting the votes on that reply id.
this is what i got so far
SELECT COUNT(voteCount)
FROM replies_table
WHERE reply_id = .../**dont know how am i suppose to do this part **/;
i know it would be something like this but i have never wrote a event scheduler