How to Escape Parenthesis in SQL

SQL queries contain certain characters that are known as "special" characters. These characters are used by the SQL processing engine and, if you include them in the literal text of your SQL query, can error out the query or cause it to be processed incorrectly. The solution to this is to write in an escape character before your special character, such as a parenthesis, that tells the SQL processing engine to consider the special character as plain text.

Instructions

    • 1

      Log in to your SQL database of choice.

    • 2

      Type out your query as you normally would, such as the following:

      SELECT * AS text FROM database WHERE id=(

      In this case, the "(" character is normally defined as a special character, but in this case it needs to be used as a comparison character.

    • 3

      Add a single quote immediately preceding the parenthesis so that it looks as follows:

      SELECT * AS text FROM database WHERE id='(

    • 4

      Run the SQL query in your database to retrieve the result.

Related Searches:

References

Comments

Related Ads

Featured