---
schema_version: "1"
id: 7ae3597b7f15e37a97344a73f9b1e8e538acd1670028b3135edb2e9b07b8efef
title: Quoted String Escape Sequences
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-soql-select-quotedstringescapes.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-select-quotedstringescapes.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d1918af4cdeea9fa77652b3c1dd71d1dfa0cd6e05763f53f07485551049c652d
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# Quoted String Escape Sequences

SOQL defines several escape sequences that are valid in queries so that you can include special characters in your queries. You can escape new lines, carriage returns, tabs, quotes, and more. The escape character for SOQL is the backslash (\\) character.

You can use the following escape sequences with SOQL:

| Sequence                   | Meaning                                                                                      |
| -------------------------- | -------------------------------------------------------------------------------------------- |
| `\n` or `\N`               | New line                                                                                     |
| `\r` or `\R`               | Carriage return                                                                              |
| `\t` or `\T`               | Tab                                                                                          |
| `\b` or `\B`               | Bell                                                                                         |
| `\f` or `\F`               | Form feed                                                                                    |
| `\"`                       | One double-quote character                                                                   |
| `\'`                       | One single-quote character                                                                   |
| `\\`                       | Backslash                                                                                    |
| LIKE expression only: `\_` | Matches a single underscore character ( \_ )                                                 |
| LIKE expression only:`\%`  | Matches a single percent sign character ( % )                                                |
| `\uXXXX`                   | A Unicode character with XXXX as the code (for example, `\u00e9` represents the é character) |

If you use a backslash character in any other context, an error occurs.

## Escaped Character Examples

**`SELECT Id FROM Account WHERE Name LIKE 'Ter%'`:** Select all accounts whose name begins with the three character sequence 'Ter'.

**`SELECT Id FROM Account WHERE Name LIKE 'Ter\%'`:** Select all accounts whose name exactly matches the four character sequence 'Ter%'.

**`SELECT Id FROM Account WHERE Name LIKE 'Ter\%%'`:** Select all accounts whose name begins with the four character sequence 'Ter%'

**See Also**

- [_Trailhead_: Secure Server-Side Development](https://trailhead.salesforce.com/content/learn/modules/secure-serverside-development)
- [_Apex Developer Guide_: SOQL Injection](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/pages_security_tips_soql_injection.htm)
