SQL Escape / Unescape

Escapes or unescapes a SQL string removing traces of offending characters that could prevent execution.

Input




Output




Applying following rules:

  • Escapes all single quote characters by doubling them. Example: SELECT * from TABLENAME where value = 'a single quote '' is escaped';


What is SQL and how to escape single quotes in SQL?

SQL or Structured Query Language is a Language for data professionals. It is undoubtedly the most important language for getting a job in the field of data analysis or data sciences. Millions of data points are being generated every minute and raw data does not have any story to tell. After all this data gets stored in databases and professionals use SQL to extract this data for further analysis. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database.
The simplest method to escape single quotes in SQL is to use two single quotes. For example, if you wanted to show the value O'Reilly, you would use two quotes in the middle instead of one. The single quote is the escape character in Oracle, SQL Server, MySQL, and PostgreSQL.