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

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

      <legend id='Bwy1X'><style id='Bwy1X'><dir id='Bwy1X'><q id='Bwy1X'></q></dir></style></legend>

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

          <bdo id='Bwy1X'></bdo><ul id='Bwy1X'></ul>
      2. <tfoot id='Bwy1X'></tfoot>

        為什么 MySQL 在 SELECT 語(yǔ)句中使用 RAND() 時(shí)返回相同

        Why is MySQL returning the same results while using RAND() in the SELECT statement?(為什么 MySQL 在 SELECT 語(yǔ)句中使用 RAND() 時(shí)返回相同的結(jié)果?)

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

        <legend id='JwRe1'><style id='JwRe1'><dir id='JwRe1'><q id='JwRe1'></q></dir></style></legend>
        <tfoot id='JwRe1'></tfoot>

          <tbody id='JwRe1'></tbody>

      3. <i id='JwRe1'><tr id='JwRe1'><dt id='JwRe1'><q id='JwRe1'><span id='JwRe1'><b id='JwRe1'><form id='JwRe1'><ins id='JwRe1'></ins><ul id='JwRe1'></ul><sub id='JwRe1'></sub></form><legend id='JwRe1'></legend><bdo id='JwRe1'><pre id='JwRe1'><center id='JwRe1'></center></pre></bdo></b><th id='JwRe1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JwRe1'><tfoot id='JwRe1'></tfoot><dl id='JwRe1'><fieldset id='JwRe1'></fieldset></dl></div>
            <bdo id='JwRe1'></bdo><ul id='JwRe1'></ul>
                • 本文介紹了為什么 MySQL 在 SELECT 語(yǔ)句中使用 RAND() 時(shí)返回相同的結(jié)果?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我打開(kāi)了許多瀏覽器窗口,指向同一個(gè)自動(dòng)刷新的 PHP 頁(yè)面.它訪問(wèn) MySQL 數(shù)據(jù)庫(kù)以識(shí)別過(guò)時(shí)的客戶信息.專門獲取最后一天未更新的記錄并強(qiáng)制更新.其余代碼似乎處理得很好.

                  I have a number of browser windows open pointing to the same auto-refreshing PHP page. It accesses a MySQL database to identify customer information that is out of date. Specifically getting records that haven't been updated in the last day and forces an update. The rest of the code seems to be processing fine.

                  這是我的 MySQLi 查詢:

                  Here is my MySQLi query:

                  $query = "SELECT *
                            FROM customers
                            WHERE customer_group='consumables' AND customer_updated < DATE_SUB(NOW(), INTERVAL 1 DAY)
                            ORDER BY RAND()
                            LIMIT 10";
                  

                  我被告知 RAND() 不是很合適,因?yàn)樗幚泶蟊淼乃俣群苈窃谶@個(gè)項(xiàng)目結(jié)束之前我的表不會(huì)增加到超過(guò) 20000.我還有一個(gè)隨機(jī)變量被傳遞到 URL,如clientdataupdates.php?nocachepls=1541231".

                  I have been informed that RAND() is not very suitable due to it's slow processing of large tables, but my tables will not increase to over 20000 before the end of this project. I also have a random variable being passed to the URL like "clientdataupdates.php?nocachepls=1541231".

                  所以這是我的問(wèn)題:在當(dāng)前的 5000 條奇數(shù)記錄中,如果該腳本同時(shí)在多個(gè)瀏覽器窗口中運(yùn)行,它們會(huì)從 MySQL 返回相同的記錄.誠(chéng)然,所選擇的記錄似乎是隨機(jī)選取的,但如果查詢?cè)谕耆嗤臅r(shí)間運(yùn)行,則會(huì)在所有窗口中返回相同的記錄.

                  So here is my problem: Out of the current 5000 odd records, if this script is run in multiple browser windows at the same time, they are getting the same records returned from MySQL. Admittedly the chosen record seems to be picked at random, but the same record is returned in all of the windows if the query is run at the exact same time.

                  我的研究受到了很大的限制,因?yàn)槲乙恢痹谒阉鞯年P(guān)鍵字(現(xiàn)在已經(jīng)幾天了)似乎與其他問(wèn)題有關(guān),例如php mysql 在使用 rand() 時(shí)返回相同的結(jié)果"有太多谷歌響應(yīng)指向一般使用 rand().

                  My research has been quite limited by the fact that they keywords I have been searching for (over a few days now) seem to relate to other problems e.g. "php mysql returning same result while using rand()" has too many google responses that point to using rand() in general.

                  雖然我仍然希望得到任何幫助,但實(shí)際上我更想知道為什么會(huì)這樣.我對(duì) MySQL 內(nèi)部工作原理的了解有限,但就我連接 PHP 和 MySQL 的所有經(jīng)驗(yàn)而言,我也沒(méi)有看到任何類似的情況發(fā)生.

                  Whilst I would still appreciate any assistance, I would actually more like to know why this is happening. My knowledge of the inner workings of MySQL is limited, but for all my experience interfacing PHP and MySQL I have not seen anything similar occur either.

                  更新:

                  我還使用包含回調(diào)函數(shù)的 ajax 函數(shù)進(jìn)行了測(cè)試,以再次啟動(dòng)它.每次div內(nèi)容都是相同的記錄——但看起來(lái)還是隨機(jī)選擇了哪條記錄.

                  I have also tested using an ajax function that includes a callback function to kick it off again. Every time the div contents are the same record - but it still looks like which record is selected at random.

                  <div id='worker1' class='workerDiv'>worker: waiting..</div>
                  <div id='worker2' class='workerDiv'>worker: waiting..</div>
                  <div id='worker3' class='workerDiv'>worker: waiting..</div>
                  <div id='worker4' class='workerDiv'>worker: waiting..</div>
                  <div id='worker5' class='workerDiv'>worker: waiting..</div>
                  <script>
                   function nextWorker(thisWorker){
                    setTimeout(function(){ ajaxpage('customerdata_worker.php',thisWorker,nextWorker(thisWorker)); }, 10000);
                   }
                   setTimeout(nextWorker('worker1'), 100);
                   setTimeout(nextWorker('worker2'), 100);
                   setTimeout(nextWorker('worker3'), 100);
                   setTimeout(nextWorker('worker4'), 100);
                   setTimeout(nextWorker('worker5'), 100);
                  </script>
                  

                  推薦答案

                  您可能在某些結(jié)果集中從 MySQL 查詢緩存接收信息.

                  You are probably receiving information from the MySQL query cache in some result sets.

                  試試這個(gè):

                  SELECT SQL_NO_CACHE *
                         /* etc */
                  

                  注意:將 SQL_NO_CACHE 字與 SELECT 和 *(或您選擇的第一列的名稱)放在同一行.

                  BEWARE: Put the SQL_NO_CACHE word on the same line as the SELECT and the * (or the name of the first column you are selecting).

                  參見(jiàn):http://dev.mysql.com/doc/refman/5.1/en/query-cache.html 它說(shuō),

                  查詢緩存將 SELECT 語(yǔ)句的文本與發(fā)送給客戶端的相應(yīng)結(jié)果.如果一個(gè)相同的稍后收到語(yǔ)句,服務(wù)器從查詢緩存,而不是再次解析和執(zhí)行語(yǔ)句.這查詢緩存在會(huì)話之間共享,因此由一個(gè)生成的結(jié)果集可以發(fā)送客戶端以響應(yīng)另一個(gè)發(fā)出的相同查詢客戶.

                  The query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again. The query cache is shared among sessions, so a result set generated by one client can be sent in response to the same query issued by another client.

                  專業(yè)提示:避免在軟件中使用 SELECT *.給出結(jié)果集中所需列的名稱.

                  Pro tip: Avoid SELECT * in software. Give the names of the columns you need in the result set.

                  這篇關(guān)于為什么 MySQL 在 SELECT 語(yǔ)句中使用 RAND() 時(shí)返回相同的結(jié)果?的文章就介紹到這了,希望我們推薦的答案對(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)文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調(diào)用未定義的函數(shù) mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準(zhǔn)備好的語(yǔ)句問(wèn)題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個(gè)結(jié)果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
                    <tbody id='NPe6a'></tbody>

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

                  <legend id='NPe6a'><style id='NPe6a'><dir id='NPe6a'><q id='NPe6a'></q></dir></style></legend>

                    <tfoot id='NPe6a'></tfoot>
                        • <bdo id='NPe6a'></bdo><ul id='NPe6a'></ul>
                            主站蜘蛛池模板: 亚洲人成一区二区三区性色 | 久久精品国产一区二区电影 | 日日网 | 人人人艹 | 国产精品高潮呻吟久久 | a视频在线 | 色婷婷婷婷色 | 国产视频二区在线观看 | 国产精品视频久久 | www国产亚洲精品 | 亚洲美女在线视频 | 久久综合久久久 | 亚洲欧美一区二区三区在线 | 国产精品久久久久久影院8一贰佰 | 久久久精品网站 | 色网站在线| 亚洲一区影院 | 亚洲成人精选 | 亚洲综合免费 | 中日av | 国产精品久久久一区二区三区 | 成人午夜精品 | 视频一区二区三区四区五区 | 中文字幕一区二区视频 | 毛片一区| 亚洲中午字幕 | 每日在线更新av | 日日夜夜天天 | 色爱av | 亚洲欧美日韩精品久久亚洲区 | 亚洲国产精品久久久 | 中文在线一区 | 国产视频三级 | 久久99精品久久久久蜜桃tv | 国产1区 | 久久国内精品 | 日韩精品人成在线播放 | 天天色天天射天天干 | 亚洲美女天堂网 | 亚洲综合色婷婷 | 中文字幕免费在线 |