10

I am a bit new to MySQL and just wanted to know what is the difference between:

`   '    "

when I'm using them in a query.

Jason
  • 13,945
  • 23
  • 82
  • 113
user963631
  • 185
  • 2
  • 8

5 Answers5

7

With ` you write mysql variable names. With ' you write mysql variable values

For example

SELECT * FROM `test` WHERE `x` = '1'
nico
  • 48,112
  • 17
  • 80
  • 111
Narek
  • 3,656
  • 3
  • 37
  • 55
7

I would add that the way double quotes are interpreted depend of wether or not your MySQL server has ANSI quotes turned on or off.

In the former you cannot use double quotes as a string delimiter.

SELECT name FROM user WHERE last_name = "norris" ;

will return you a punch in your teeth.

Stan
  • 7,968
  • 2
  • 26
  • 30
  • The link is broken. A version-agnostic way seems to work. http://dev.mysql.com/doc/refman/en/sql-mode.html#sqlmode_ansi_quotes – Melebius May 17 '16 at 07:08
2

``quotes you dont need to escape where as string quotes you do ''single or ""double

Philip
  • 4,596
  • 2
  • 17
  • 28
1

use ` (backquotes) for column name

use ' or " for values

Don't use backticks with column values. use either single or double quotes otherwise mysql considered that value as a column name.

Pradeep Singh
  • 3,424
  • 3
  • 26
  • 41