title: MySQL string comparison using LIKE in store procedure
body: <p>how can I make a string comparison in order to detect if a string begins with 12% or 13% using like statement? this store procedure gives me an error and using prepared statements are very very tricky, so can someone please help me on this?</p>
  
  <pre><code>    DELIMITER ;;
      CREATE PROCEDURE `insert_trackingtest`(IN deviceid VARCHAR(15),IN timing timestamp,IN valid tinyint(1),IN latitude double,IN longitude double,IN speed double,IN course double,IN power double,IN comando varchar(45))
      BEGIN
          IF deviceid LIKE CONCAT('12','%') OR deviceid LIKE CONCAT('13','%') THEN
              SET @deviceid = CONCAT('0',deviceid);
          ELSE
              SET @deviceid = deviceid;
          END IF;
          SET @query = properprepare('INSERT INTO tracking_? (device_id,time,valid,latitude,longitude,speed,course,power,command) VALUES (?,?,?,?,?,?,?,?,?)',@deviceid);
          PREPARE stmt FROM @query;
          SET @imei = deviceid;
          SET @timing = timing;
          SET @valid = valid;
          SET @latitude = latitude;
          SET @longitude = longitude;
          SET @speed = speed;
          SET @course = course;
          SET @power = power;
          SET @comando = comando;
          EXECUTE stmt USING @deviceid,@timing,@valid,@latitude,@longitude,@speed,@course,@power,@comando;
      END ;;
      DELIMITER ;
  </code></pre>