You said I should give the table a trigger,
But how to build, haven't got a clue
If not, what method can solve?
CodePudding user response:
Resolved:Create the TRIGGER first_trigger AFTER INSERT on the comment
For each row
The begin
The UPDATE articles set comment_num=(select COUNT (title_id) from the comment where title_id=new. Title_id)
Where title_id=new. Title_id;
end
CodePudding user response:
Trigger is not appropriate, impact performance, also do not conform to the norm, the trigger to cannot use,This kind of situation, it is ok to create a view, using table to store has a problem,
CodePudding user response:
But without the trigger, I will use three SQL queryI deal with things like our this CSDN the "reply number
"That you said that good
CodePudding user response:
I know the solution to this problem nowIs here again, the implementation of three times the update operation, but in order to ensure the consistency of the data, need in the Java code inside the