- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Facing difficulty in removing the apostrophe in MySQL stored procedure?
To remove apostrophe, replace it. For this, you can use REPLACE(). Following is the syntax −
SET anyVariableName = REPLACE(yourVaribleName , '\'', '');
To understand the above syntax, let us create a stored procedure to remove the apostrophe in 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 // Query OK, 0 rows affected (0.15 sec) mysql> DELIMITER ;
Call the stored procedure using CALL command −
mysql> CALL remove_Apostrophe("Introduction to My'SQL");
This will produce the following output −
+----------------------------------------------------------------+ | CONCAT("AFTER REMOVING APOSTROPHE THE STRING IS= ", Value) | +----------------------------------------------------------------+ | AFTER REMOVING APOSTROPHE THE STRING IS= Introduction to MySQL | +----------------------------------------------------------------+ 1 row in set (0.00 sec) Query OK, 0 rows affected, 1 warning (0.01 sec)
Advertisements