Skip to content

Instantly share code, notes, and snippets.

@gabrieledarrigo
Created May 8, 2013 09:14
Show Gist options
  • Save gabrieledarrigo/5539264 to your computer and use it in GitHub Desktop.
Save gabrieledarrigo/5539264 to your computer and use it in GitHub Desktop.
An Sql trigger example.
DELIMITER $$
CREATE TRIGGER ai_photogallery AFTER INSERT ON photogallery_item
FOR EACH ROW
BEGIN
UPDATE photogallery_master
SET file =
(SELECT file FROM photogallery_item WHERE id_photogallery = NEW.id_photogallery ORDER BY ordine DESC LIMIT 1)
WHERE id = NEW.id_photogallery;
END;
$$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment