久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='3khAm'><tr id='3khAm'><dt id='3khAm'><q id='3khAm'><span id='3khAm'><b id='3khAm'><form id='3khAm'><ins id='3khAm'></ins><ul id='3khAm'></ul><sub id='3khAm'></sub></form><legend id='3khAm'></legend><bdo id='3khAm'><pre id='3khAm'><center id='3khAm'></center></pre></bdo></b><th id='3khAm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3khAm'><tfoot id='3khAm'></tfoot><dl id='3khAm'><fieldset id='3khAm'></fieldset></dl></div>

      <legend id='3khAm'><style id='3khAm'><dir id='3khAm'><q id='3khAm'></q></dir></style></legend>
      <tfoot id='3khAm'></tfoot>
      • <bdo id='3khAm'></bdo><ul id='3khAm'></ul>

      <small id='3khAm'></small><noframes id='3khAm'>

      1. 何時(shí)在 MySQL 中使用單引號(hào)、雙引號(hào)和反引號(hào)

        When to use single quotes, double quotes, and backticks in MySQL(何時(shí)在 MySQL 中使用單引號(hào)、雙引號(hào)和反引號(hào))
            <i id='Q2Pwe'><tr id='Q2Pwe'><dt id='Q2Pwe'><q id='Q2Pwe'><span id='Q2Pwe'><b id='Q2Pwe'><form id='Q2Pwe'><ins id='Q2Pwe'></ins><ul id='Q2Pwe'></ul><sub id='Q2Pwe'></sub></form><legend id='Q2Pwe'></legend><bdo id='Q2Pwe'><pre id='Q2Pwe'><center id='Q2Pwe'></center></pre></bdo></b><th id='Q2Pwe'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Q2Pwe'><tfoot id='Q2Pwe'></tfoot><dl id='Q2Pwe'><fieldset id='Q2Pwe'></fieldset></dl></div>
              <bdo id='Q2Pwe'></bdo><ul id='Q2Pwe'></ul>
                <tbody id='Q2Pwe'></tbody>

              <small id='Q2Pwe'></small><noframes id='Q2Pwe'>

            • <legend id='Q2Pwe'><style id='Q2Pwe'><dir id='Q2Pwe'><q id='Q2Pwe'></q></dir></style></legend>
              <tfoot id='Q2Pwe'></tfoot>

                  本文介紹了何時(shí)在 MySQL 中使用單引號(hào)、雙引號(hào)和反引號(hào)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在努力學(xué)習(xí)編寫查詢的最佳方式.我也明白保持一致的重要性.直到現(xiàn)在,我都沒(méi)有任何真正的想法,隨意使用了單引號(hào)、雙引號(hào)和反引號(hào).

                  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.

                  示例:

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

                  另外,在上面的例子中,考慮到tablecol1val1等可能是變量.

                  Also, in the above example, consider that table, col1, val1, etc. may be variables.

                  這是什么標(biāo)準(zhǔn)?你是做什么的?

                  What is the standard for this? What do you do?

                  我已經(jīng)在這里閱讀了大約 20 分鐘的類似問(wèn)題的答案,但這個(gè)問(wèn)題似乎沒(méi)有明確的答案.

                  推薦答案

                  反引號(hào)用于表和列標(biāo)識(shí)符,但僅當(dāng)標(biāo)識(shí)符是 MySQL 保留關(guān)鍵字,或者當(dāng)標(biāo)識(shí)符包含空白字符或超出限制集的字符時(shí)(見(jiàn)下文)通常建議盡可能避免使用保留關(guān)鍵字作為列或表標(biāo)識(shí)符,避免引用問(wèn)題.

                  Backticks are to be used for table and column identifiers, but are only necessary when the identifier is a MySQL reserved keyword, or when the identifier contains whitespace characters or characters beyond a limited set (see below) It is often recommended to avoid using reserved keywords as column or table identifiers when possible, avoiding the quoting issue.

                  單引號(hào)應(yīng)該用于像 VALUES() 列表中的字符串值.MySQL 也支持字符串值的雙引號(hào),但其他 RDBMS 更廣泛地接受單引號(hào),因此使用單引號(hào)代替雙引號(hào)是一個(gè)好習(xí)慣.

                  Single quotes should be used for string values like in the VALUES() list. Double quotes are supported by MySQL for string values as well, but single quotes are more widely accepted by other RDBMS, so it is a good habit to use single quotes instead of double.

                  MySQL 還期望 DATEDATETIME 文字值被單引號(hào)作為字符串,如 '2001-01-01 00:00:00'.查閱日期和時(shí)間文字文檔有關(guān)更多詳細(xì)信息,特別是使用連字符 - 作為日期字符串中的段分隔符的替代方法.

                  MySQL also expects DATE and DATETIME literal values to be single-quoted as strings like '2001-01-01 00:00:00'. Consult the Date and Time Literals documentation for more details, in particular alternatives to using the hyphen - as a segment delimiter in date strings.

                  因此,使用您的示例,我會(huì)用雙引號(hào)引用 PHP 字符串并在值 'val1', 'val2' 上使用單引號(hào).NULL 是一個(gè) MySQL 關(guān)鍵字,是一個(gè)特殊的(非)值,因此不加引號(hào).

                  So using your example, I would double-quote the PHP string and use single quotes on the values 'val1', 'val2'. NULL is a MySQL keyword, and a special (non)-value, and is therefore unquoted.

                  這些表或列標(biāo)識(shí)符都不是保留字或使用需要引用的字符,但我還是用反引號(hào)引用了它們(稍后會(huì)詳細(xì)介紹...).

                  None of these table or column identifiers are reserved words or make use of characters requiring quoting, but I've quoted them anyway with backticks (more on this later...).

                  不應(yīng)引用 RDBMS 的本機(jī)函數(shù)(例如,MySQL 中的 NOW()),盡管它們的參數(shù)受已提及的相同字符串或標(biāo)識(shí)符引用規(guī)則的約束.

                  Functions native to the RDBMS (for example, NOW() in MySQL) should not be quoted, although their arguments are subject to the same string or identifier quoting rules already mentioned.

                  Backtick (`)
                  table & column ───────┬─────┬──┬──┬──┬────┬──┬────┬──┬────┬──┬───────┐
                                        ↓     ↓  ↓  ↓  ↓    ↓  ↓    ↓  ↓    ↓  ↓       ↓
                  $query = "INSERT INTO `table` (`id`, `col1`, `col2`, `date`, `updated`) 
                                         VALUES (NULL, 'val1', 'val2', '2001-01-01', NOW())";
                                                 ↑↑↑↑  ↑    ↑  ↑    ↑  ↑          ↑  ↑↑↑↑↑ 
                  Unquoted keyword          ─────┴┴┴┘  │    │  │    │  │          │  │││││
                  Single-quoted (') strings ───────────┴────┴──┴────┘  │          │  │││││
                  Single-quoted (') DATE    ───────────────────────────┴──────────┘  │││││
                  Unquoted function         ─────────────────────────────────────────┴┴┴┴┘    
                  

                  變量插值

                  變量的引用模式不會(huì)改變,但如果您打算直接在字符串中插入變量,則必須在 PHP 中使用雙引號(hào).只要確保您已正確轉(zhuǎn)義在 SQL 中使用的變量.(建議使用支持預(yù)處理語(yǔ)句的 API,以防止 SQL 注入).

                  // Same thing with some variable replacements
                  // Here, a variable table name $table is backtick-quoted, and variables
                  // in the VALUES list are single-quoted 
                  $query = "INSERT INTO `$table` (`id`, `col1`, `col2`, `date`) VALUES (NULL, '$val1', '$val2', '$date')";
                  

                  準(zhǔn)備好的語(yǔ)句

                  處理準(zhǔn)備好的語(yǔ)句時(shí),請(qǐng)查閱文檔以確定是否必須引用語(yǔ)句的占位符.PHP、PDO 和 MySQLi 中最流行的 API 需要不帶引號(hào)的占位符,其他語(yǔ)言的大多數(shù)準(zhǔn)備好的語(yǔ)句 API 也是如此:

                  Prepared statements

                  When working with prepared statements, consult the documentation to determine whether or not the statement's placeholders must be quoted. The most popular APIs available in PHP, PDO and MySQLi, expect unquoted placeholders, as do most prepared statement APIs in other languages:

                  // PDO example with named parameters, unquoted
                  $query = "INSERT INTO `table` (`id`, `col1`, `col2`, `date`) VALUES (:id, :col1, :col2, :date)";
                  
                  // MySQLi example with ? parameters, unquoted
                  $query = "INSERT INTO `table` (`id`, `col1`, `col2`, `date`) VALUES (?, ?, ?, ?)";
                  

                  需要在標(biāo)識(shí)符中使用反引號(hào)的字符:

                  根據(jù) MySQL 文檔,您不需要使用以下字符集的引用(反引號(hào))標(biāo)識(shí)符:

                  Characters requring backtick quoting in identifiers:

                  According to MySQL documentation, you do not need to quote (backtick) identifiers using the following character set:

                  ASCII:[0-9,a-z,A-Z$_](基本拉丁字母、數(shù)字0-9、美元、下劃線)

                  ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)

                  您可以使用超出該設(shè)置的字符作為表或列標(biāo)識(shí)符,例如包括空格,但是您必須引用(反引號(hào))它們.

                  You can use characters beyond that set as table or column identifiers, including whitespace for example, but then you must quote (backtick) them.

                  此外,盡管數(shù)字是標(biāo)識(shí)符的有效字符,但標(biāo)識(shí)符不能僅由數(shù)字組成.如果他們這樣做,他們必須用反引號(hào)包裹起來(lái).

                  Also, although numbers are valid characters for identifiers, identifiers cannot consist solely of numbers. If they do they must be wrapped in backticks.

                  這篇關(guān)于何時(shí)在 MySQL 中使用單引號(hào)、雙引號(hào)和反引號(hào)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) N 個(gè)先前值來(lái)決定接下來(lái)的 N 個(gè)行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數(shù)的 ignore 選項(xiàng)是忽略整個(gè)事務(wù)還是只是有問(wèn)題的行?) - IT屋-程序員軟件開(kāi)發(fā)技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時(shí)出錯(cuò),使用 for 循環(huán)數(shù)組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調(diào)用 o23.load 時(shí)發(fā)生錯(cuò)誤 沒(méi)有合適的驅(qū)動(dòng)程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫(kù)表作為 Spark 數(shù)據(jù)幀讀取?)

                    <bdo id='mhTzH'></bdo><ul id='mhTzH'></ul>
                    <legend id='mhTzH'><style id='mhTzH'><dir id='mhTzH'><q id='mhTzH'></q></dir></style></legend>
                  • <i id='mhTzH'><tr id='mhTzH'><dt id='mhTzH'><q id='mhTzH'><span id='mhTzH'><b id='mhTzH'><form id='mhTzH'><ins id='mhTzH'></ins><ul id='mhTzH'></ul><sub id='mhTzH'></sub></form><legend id='mhTzH'></legend><bdo id='mhTzH'><pre id='mhTzH'><center id='mhTzH'></center></pre></bdo></b><th id='mhTzH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mhTzH'><tfoot id='mhTzH'></tfoot><dl id='mhTzH'><fieldset id='mhTzH'></fieldset></dl></div>

                          1. <small id='mhTzH'></small><noframes id='mhTzH'>

                              <tbody id='mhTzH'></tbody>
                            <tfoot id='mhTzH'></tfoot>
                            主站蜘蛛池模板: 岛国精品| av电影一区二区 | 国产精品欧美日韩 | 成人av网站在线观看 | 日韩精品免费在线观看 | 精品综合久久 | 在线视频一区二区三区 | 亚洲欧洲在线视频 | 久久久亚洲成人 | 亚洲第一中文字幕 | jlzzjlzz国产精品久久 | 欧美成人影院在线 | 伊人在线视频 | 中文字幕av在线一二三区 | 成人av一区二区三区 | 欧美视频二区 | xx性欧美肥妇精品久久久久久 | 国产精品178页 | 国产激情在线观看 | 久久久久久久久99 | 亚洲精品视频在线 | 黄色国产在线视频 | 国产精品久久久久久久久久99 | 久久一二| 日本不卡免费新一二三区 | 一区二区三区免费网站 | 国产 日韩 欧美 中文 在线播放 | 国产91精品久久久久久久网曝门 | 亚洲精品一区中文字幕乱码 | 亚洲在线日韩 | 色av一区二区| 日韩精品一区二区不卡 | 成人免费毛片在线观看 | 涩涩视频在线观看免费 | 国产伦精品一区二区三区精品视频 | 精品日韩一区 | 91污在线| 天天操夜夜操 | 国产精品99久久久久久大便 | 午夜在线影院 | 日韩天堂av |