MySQL's different quote marks

后端 未结 5 440
有刺的猬
有刺的猬 2020-12-17 20:27

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.

相关标签:
5条回答
  • 2020-12-17 20:53

    http://dev.mysql.com/doc/refman/5.1/en/string-literals.html

    http://dev.mysql.com/doc/refman/5.1/en/identifiers.html

    0 讨论(0)
  • 2020-12-17 20:54

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

    For example

    SELECT * FROM `test` WHERE `x` = '1'
    
    0 讨论(0)
  • 2020-12-17 20:57

    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.

    0 讨论(0)
  • 2020-12-17 21:11

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

    0 讨论(0)
  • 2020-12-17 21:13

    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.

    0 讨论(0)
提交回复
热议问题