How to Insert a Single Quote in SQL Database: SQL Oracle MySQL PostgreSQL SQLite SQL Server Operators: INSERT Problem: You want to insert a record that contains a single quote symbol, e.g., "O’Hara", into an SQL table. Example: Our database has a table named employees with data in the following columns: id (primary key), first_name, last_name, and department. idfirst_namelast_namedepartment 1MichaelTaylorHR 2MilesReeseSales 3KarlRuralSales 4OliviaScottManager Let’s say we want to insert a new employee in the sales department: William O’Hara. It results in a syntax error if you write it as is. The apostrophe is treated as if it is a closing quote for a string value. Solution: To avoid the syntax error, replace the apostrophe with two single quote symbols: INSERT INTO employees(id, first_name, last_name, department) VALUES (5, 'William', 'O''Hara', 'Sales'); SELECT * FROM employees; The result of the query is: idfirst_namelast_namedepartment 1MichaelTaylorHR 2MilesReeseSales 3KarlRuralSales 4OliviaScottManager 5WilliamO’HaraSales Discussion: This solution is universal for every SQL dialect. Apostrophes entered by this method are also stackable. That is, use four single quotes if you have two apostrophes, and so on. It is also worth noting that this method may be used in any query and anywhere in a query. For example, it is allowed in a WHERE or HAVING clause in a SELECT query. Recommended courses: How to insert, update, or delete data in SQL SQL Practice Set Recommended articles: SQL INSERT, SQL UPDATE, SQL DELETE – Oh My! 5 SQL Functions for Manipulating Strings Standard SQL Functions Cheat Sheet Subscribe to our newsletter Join our monthly newsletter to be notified about the latest posts. Email address How Do You Write a SELECT Statement in SQL? What Is a Foreign Key in SQL? Enumerate and Explain All the Basic Elements of an SQL Query