inexperienced SQL user here.
I am currently working on a forum where posts need to have an upvote/downvote system.
My current sql(phpmyadmin) structure is like this:
Table 1 (posts) post_id | post_title | post_score
Table 2 (pvotes) pvote_id | fk_post_id | fk_user_id | pvote_score
I want to somehow make post_score (in table 1), find all pvote_score(table 2) collumns and add/subtract them together, where fk_post_id(table 2) is = to post_id(table 1)
This way i hope to make a voting system that only allows every user to vote once, and automatically calculate a posts post_score from the pvote_score values.
EDIT:
Sorry if question wasnt clear enough. I want to know how i can make the post_score collumn automatically add/subtract the values from pvotes_score and show the sum as its value
Thank you for your attention, hope you can help :-)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire