什么时候在MySQL中使用单引号,双引号和反引号 - When to use single quotes, double quotes, and backticks in MySQL

问题:

I am trying to learn the best way to write queries. 我正在尝试学习编写查询的最佳方法。 I also understand the importance of being consistent. 我也了解保持一致的重要性。 Until now, I have randomly used single quotes, double quotes, and backticks without any real thought. 到如今为止,我在没有任何实际考虑的状况下随机使用单引号,双引号和反引号。 dom

Example: 例: ide

$query = 'INSERT INTO table (id, col1, col2) VALUES (NULL, val1, val2)';

Also, in the above example, consider that table , col1 , val1 , etc. may be variables. 另外,在上面的示例中,请考虑tablecol1val1等能够是变量。 学习

What is the standard for this? 这是什么标准? What do you do? 你是作什么? this

I've been reading answers to similar questions on here for about 20 minutes, but it seems like there is no definitive answer to this question. 我已经在这里阅读了大约20分钟的相似问题的答案,可是彷佛没有确切的答案。 spa


解决方案:

参考一: https://stackoom.com/question/lVEh/什么时候在MySQL中使用单引号-双引号和反引号
参考二: https://oldbug.net/q/lVEh/When-to-use-single-quotes-double-quotes-and-backticks-in-MySQL
相关文章
相关标签/搜索