在删除MySQL存储过程中的撇号时遇到困难吗?
要删除撇号,请更换它。为此,您可以使用REPLACE()
。以下是语法-
SET anyVariableName = REPLACE(yourVaribleName , '\'', '');
为了理解上述语法,让我们创建一个存储过程来删除MySQL中的撇号-
mysql> DELIMITER // mysql> CREATE PROCEDURE remove_Apostrophe(IN Value VARCHAR(200)) BEGIN SET Value = REPLACE(Value , '\'', ''); SELECT CONCAT("AFTER REMOVING APOSTROPHE THE STRING IS= ", Value); END // mysql> DELIMITER ;
使用CALL命令调用存储过程-
mysql> CALL remove_Apostrophe("Introduction to My'SQL");
这将产生以下输出-
+----------------------------------------------------------------+ | CONCAT("AFTER REMOVING APOSTROPHE THE STRING IS= ", Value) | +----------------------------------------------------------------+ | AFTER REMOVING APOSTROPHE THE STRING IS= Introduction to MySQL | +----------------------------------------------------------------+ 1 row in set (0.00 sec)