MySQL's different quote marks

烂漫一生 提交于 2019-11-30 03:04:24

问题


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.


回答1:


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

For example

SELECT * FROM `test` WHERE `x` = '1'



回答2:


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.




回答3:


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




回答4:


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

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




回答5:


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.



来源:https://stackoverflow.com/questions/8642644/mysqls-different-quote-marks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!