title: "Delimiter" is not valid at this position, expecting CREATE
body: <p>I was getting an error of &quot;Delimiter&quot; is not valid at this position, expecting CREATE&quot; as I was writing a stored procedure and couldn't figure out the cause. I think it might be an issue with MySQL workbench possibly, because the following code gives the same error but was copied straight off of <a href="https://www.mysqltutorial.org/variables-in-stored-procedures.aspx/" rel="nofollow noreferrer">this website</a>.</p>
  <pre class="lang-sql prettyprint-override"><code>DELIMITER $$
  CREATE PROCEDURE GetTotalOrder()
  BEGIN
      DECLARE totalOrder INT DEFAULT 0;
      
      SELECT COUNT(*) 
      INTO totalOrder
      FROM orders;
      
      SELECT totalOrder;
  END$$
  DELIMITER ;
  </code></pre>
  <p><strong>Edit:</strong> My real stored procedure is:</p>
  <pre class="lang-sql prettyprint-override"><code>DELIMITER //
  CREATE PROCEDURE GetSimilar(inputdate char(10))
  BEGIN
      Declare id(tinyint) DEFAULT 0;
      Set id := (select t.IdTimelineinfo
          From timelineinfo t
          WHERE t.Date = inputdate);
      SELECT t.Date From timelineinfo t where t.date = inputdate;
      SELECT o.Name, o.Race, o.Sex, o.IdOfficer
          FROM timelineinfo
          JOIN timelineinfo_officer ON timelineinfo.IdTimelineinfo = timelineinfo_officer.IdTimelineinfo      
          JOIN officers o ON timelineinfo_officer.IdOfficer = o.IdOfficer
          WHERE timelineinfo.IdTimelineinfo = id
          UNION
      SELECT s.IdSubject, s.Name, s.Race, s.Sex
          FROM timelineinfo
          JOIN timelineinfo_subject ON timelineinfo.IdTimelineinfo = timelineinfo_subject.IdTimelineinfo      
          JOIN subjects s ON timelineinfo_subject.IdSubject = s.IdSubject
          WHERE timelineinfo.IdTimelineinfo = id;
          UNION
      Select * 
          From media m
          Where (m.IdTimelineinfo = id);
  END //
  DELIMITER ;
  </code></pre>