MySQL Single, Double & Backtick Quotes Explained
In MySQL, the type of quote you use around a value or a name changes what it means – and mixing them up is a classic cause of syntax errors. This guide explains when to use single quotes, backticks, and double quotes, with clear examples.
Single MySQL quotes: for string values
Single quotes wrap string literals – the actual text values you insert or compare. For example, the values in an INSERT go in single quotes:
INSERT INTO `products` VALUES ('Keyboard', 'In stock');Backticks: for names
Backticks wrap identifiers – the names of databases, tables, and columns. You mainly need them when a name is also a reserved MySQL word, such as password or order. Backticks tell MySQL “this is a name, not a keyword”:
INSERT INTO `users` (`username`, `password`)
VALUES ('user1', 'hashed_password');Here only password strictly needs backticks, because it’s a reserved word – but quoting all identifiers with backticks is a safe, consistent habit.
Double quotes: it depends
Double MySQL quotes are the tricky one. By default MySQL treats them like single quotes (a string), but if the server runs in ANSI_QUOTES mode they behave like backticks (an identifier) instead. Because the meaning changes with the server setting, it’s best to avoid double quotes in MySQL – use single quotes for values and backticks for names, and your queries work everywhere. This is also why copying SQL from another database system, where double quotes are standard for names, sometimes fails on MySQL until you swap them for backticks.
JetHost Experts Tip
Simple rule to remember: single quotes for the data, backticks for the names. If a query throws a syntax error near a column called something like order or group, wrap that name in backticks – it’s a reserved word.
Quotes inside your text
What if the value itself contains a quote – a name like O’Brien, for instance? You have two options. Double the single quote inside the string ('O''Brien'), or place a backslash before it ('O\'Brien'). Both tell MySQL the quote is part of the text, not the end of the string. This matters for more than tidy queries: unescaped quotes in user input are exactly how SQL injection attacks work. In real applications, always use parameterised queries or your framework’s escaping functions rather than building SQL by joining strings together, so quotes in the data can never break – or hijack – your query.
Related: MySQL character set & collation, phpMyAdmin.
Need more help?
Stuck on a stubborn query? Open a ticket through Client Area → Support Tickets and our team will take a look.


