 CREATE TRIGGER `estatecat_piece` AFTER INSERT ON `estate`  FOR EACH ROW  BEGIN  UPDATE estate_category set piece = (Select count(*) from estate where estate.estatecat_id=new.estatecat_id);  ERROR 0000 (00000): You have an error in your SQL syntax; check the   manual that corresponds to your MySQL server version for the right   syntax to use near '