So I have the following problem.
The problem concerns 3 columns: upvote, downvote, score where
score is created by taking upvote/downvote
I now want to create a trigger which will update my
score column after either the
upvote or the
downvote where updated.
I looked at a bunch of stuff online and tried several things but never got it to work.
Including something like this.
create trigger trigger1 after update of (up or down) on table1 for score
set new.score =concat(up/down);
I've never created triggers before so this is completely new for me.
score doesn't belong as a column in the table, it can be calculated on the fly from the other two columns.
I agree that it should be like that in most cases, however if I create the score in my php file I have a problem with displaying the content once I order the table.
If I had the extra column this problem wouldn't exist. I know this might not be the best way but it is definitely a way that will work.
no you don't --
ORDER BY upvote/downvote
Yes that works, but there are formulas which are better suited for a rating system so that 2up 1down dont have the same effect as 200up and 100down.
Thus I think if I can create a column with that formula I wont run into any problems with urlencoding a plus sign and stuff like that.
right and you've now just created a whole new scenario from your original haven't you?
Ok, sorry about that,
I wanted to make up a simple scenario to make it as clear as possible.
I was not expecting people to tell me that I should use alternative ways.
This topic is now closed. New replies are no longer allowed.