w3resource

SQLite quote() function

Description

The quote(X) function returns a string which is the value of its argument suitable for inclusion into another SQL statement. Strings are surrounded by single-quotes with escapes on interior quotes as needed.

Syntax:

quote(X);

Argument:

Name Description
X A string.

SQLite Version : 3.8.5

Example of SQLite quote() function

The following SQLite statement returns a string 'w3re' 'source'.

SELECT quote('w3re''source');

Here is the result.

Sample Output:

quote('w3re''source')
------------------------------
'w3re''source'

Example of SQLite quote() function using table

Sample table: departments


The following statement returns the department_name and department_name enclosed with a single quote for those departments whose department_id is larger than 100.

SELECT department_name, quote(department_name) 
FROM departments
WHERE department_id>150;

Here is the result.

Sample Output:

department_name  quote(department_name)
---------------  ----------------------
Marketing        'Marketing'
Purchasing       'Purchasing'
Human Resources  'Human Resources'
Shipping         'Shipping'
IT               'IT'
Public Relation  'Public Relations'
Sales            'Sales'
Executive        'Executive'
Benefits         'Benefits'
Manufacturing    'Manufacturing'
Construction     'Construction'
Contracting      'Contracting'
Operations       'Operations'
IT Support       'IT Support'
NOC              'NOC'
IT Helpdesk      'IT Helpdesk'
Government Sale  'Government Sales'
Retail Sales     'Retail Sales'
Recruiting       'Recruiting'
Payroll          'Payroll'

Previous: nullif()
Next: random()