Today I Learned

hashrocket A Hashrocket project

Escaping A Quote In A String

In PostgreSQL, string (varchar and text) literals are declared with single quotes ('). That means that any string containing a single quote will need some escaping. The way to escape a single quote is with another single quote.

> select 'what''s up!';
 what's up!


See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.