title: MySQL declare variable in trigger error
body: <p>Anybody know what's wrong with my trigger declaration?</p>
  
  <pre><code>CREATE TRIGGER `sch_trigger_curriculum_subject_before_insert` BEFORE INSERT ON  
  `sch_curriculum_subject` FOR EACH ROW 
  BEGIN
     DECLARE curriculum_code VARCHAR(50);        
     SET curriculum_code = SELECT code FROM sch_curriculum WHERE id=NEW.id;
     SET NEW.`code_name` = CONCAT(curriculum_code,' - ', NEW.code,' - (',NEW.name,')');
  END;
  </code></pre>
  
  <p>The error: SQL Error(1064): You have error in you SQL syntax ..... near '' at line 4.</p>
  
  <p>According to error message, there is something wrong with my curriculum_code declaration. But I cant find out what's wrong.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>UPDATE:</strong>
  already solved, the problem is on delimiter, here is the working one</p>
  
  <pre><code>DELIMITER $$
  CREATE TRIGGER `sch_trigger_curriculum_subject_before_insert` BEFORE INSERT ON  
  `sch_curriculum_subject` FOR EACH ROW 
  BEGIN
    DECLARE curriculum_code VARCHAR(50);        
    SET curriculum_code = (SELECT code FROM sch_curriculum WHERE id=NEW.id);
    SET NEW.`code_name` = CONCAT(curriculum_code,' - ', NEW.code,' - (',NEW.name,')');
  END$$
  </code></pre>