How to pass any character (escape characters) to a Stored Procedure

Posted on 2014-07-14
Last Modified: 2014-07-14
I have the following how can I pass any character to the following - a double quote breaks it.

CREATE  PROCEDURE `sproc_Search_All`(IN inQ varchar(100))


 set inQ=replace(inQ,'''','''''');

 set @qs = "SELECT *  FROM CUSTOMERS "

 set @qs = concat(@qs," AND ( ", "NAME  like '%", inQ, "%' ");

 set @qs = concat(@qs,") ORDER BY NAME ");

 PREPARE preparedstatement FROM @qs ;

 EXECUTE preparedstatement;

 DEALLOCATE PREPARE preparedstatement;
Question by:JElster
    1 Comment
    LVL 11

    Accepted Solution

    Escape the quotes with \

    MySQL recognizes the following escape sequences.
    \0  An ASCII NUL (0x00) character.
    \'  A single quote (“'”) character.
    \"  A double quote (“"”) character.
    \b  A backspace character.
    \n  A newline (linefeed) character.
    \r  A carriage return character.
    \t  A tab character.
    \Z  ASCII 26 (Control-Z). See note following the table.
    \\  A backslash (“\”) character.
    \%  A “%” character. See note following the table.
    \_  A “_” character. See note following the table.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now