mysql - Update a second table, using trigger -


I am trying to create a simple trigger, but, if I media Price comes from @total or @sum then the value on Proto is that I already have the option to test the option for "1" or "1 + 1" Tested to see if I was not updating properly or the problem was the operation itself.

  DELIMITER $$ Start triggering ratings before joining the rating for each line SET @total = @total + 1; SET @sum = NEW.stars + @sum; Update Prato P SET p.media = @ sum / @ total WHERE p.id = 1; End; $$ DELIMITER;   

Any ideology?

I triggers on for each line . I thought, every time it was updated, it would move to run all the rows but, instead, it is implemented for each line which was updated , which could makes.

This was my last result of the trigger, to add and update ratings (which prato )

  DELIMITER $$ After inserting the trigger, after putting the INSERT on the rating for each line, if- (New.food_id is not empty) then SET @ media = (SELECT SUM (stars)) for ratings where food_id = NEW.food_id / ( SELECT COUNT (*) from ratings where food_id = NEW.food_id); Apated foods set F. Rate = Media @ WHERE f.id = NEW.food_id; Compare SEET Media = (WHERE restaurant_id = NEW.restaurant_id from SELECT SUM (Stars) ratings) / (Selected COUNT (*) ratings from WHERE restaurant_id = NEW.restaurant_id); One ???? Restaurant r set rrrrr = @ media WHERE r.id = NEW.restaurant_id; end if; END    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -