如何使用like语句进行字符串比较以检测字符串是否以12%或13%开头?这个商店程序给我一个错误,使用准备好的陈述是非常棘手的,所以有人可以帮我这个吗?
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 ;