I need some help with a mysql trigger. I am currently trying to tidy up some code and offload some processing to the mysql database rather than running 2 queries and joins etc…
When someone inserts into a video into a database, I would like the video count in the category to update.
So you specify the category id.
This is what I have so far so any help would be good as i just dont seem to be able to get the syntax correct.
CREATE TRIGGER 'db_videos'.'update_video_count'
AFTER INSERT ON 'videos' FOR EACH ROW
BEGIN
UPDATE video_cat WHERE video_count = video_count + 1 WHERE video_cat = video_cat;
END;
Your where clause is duplicated and ambiguous. If I understand your data model correct, try: