pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    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="eugk20e" 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 語句中使用 RAND() 時返回相同

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

        <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="m2acuci" 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 語句中使用 RAND() 時返回相同的結果?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我打開了許多瀏覽器窗口,指向同一個自動刷新的 PHP 頁面.它訪問 MySQL 數據庫以識別過時的客戶信息.專門獲取最后一天未更新的記錄并強制更新.其余代碼似乎處理得很好.

                  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() 不是很合適,因為它處理大表的速度很慢,但是在這個項目結束之前我的表不會增加到超過 20000.我還有一個隨機變量被傳遞到 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".

                  所以這是我的問題:在當前的 5000 條奇數記錄中,如果該腳本同時在多個瀏覽器窗口中運行,它們會從 MySQL 返回相同的記錄.誠然,所選擇的記錄似乎是隨機選取的,但如果查詢在完全相同的時間運行,則會在所有窗口中返回相同的記錄.

                  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.

                  我的研究受到了很大的限制,因為我一直在搜索的關鍵字(現在已經幾天了)似乎與其他問題有關,例如php mysql 在使用 rand() 時返回相同的結果"有太多谷歌響應指向一般使用 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.

                  雖然我仍然希望得到任何幫助,但實際上我更想知道為什么會這樣.我對 MySQL 內部工作原理的了解有限,但就我連接 PHP 和 MySQL 的所有經驗而言,我也沒有看到任何類似的情況發生.

                  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.

                  更新:

                  我還使用包含回調函數的 ajax 函數進行了測試,以再次啟動它.每次div內容都是相同的記錄——但看起來還是隨機選擇了哪條記錄.

                  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>
                  

                  推薦答案

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

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

                  試試這個:

                  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).

                  參見:http://dev.mysql.com/doc/refman/5.1/en/query-cache.html 它說,

                  查詢緩存將 SELECT 語句的文本與發送給客戶端的相應結果.如果一個相同的稍后收到語句,服務器從查詢緩存,而不是再次解析和執行語句.這查詢緩存在會話之間共享,因此由一個生成的結果集可以發送客戶端以響應另一個發出的相同查詢客戶.

                  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.

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

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

                  這篇關于為什么 MySQL 在 SELECT 語句中使用 RAND() 時返回相同的結果?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  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="uayogeu" 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>
                            主站蜘蛛池模板: 超声波焊接机_超音波熔接机_超声波塑焊机十大品牌_塑料超声波焊接设备厂家 | 协议书_协议合同格式模板范本大全| 发电机组|柴油发电机组-批发,上柴,玉柴,潍柴,康明斯柴油发电机厂家直销 | 食安观察网| 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 净化车间装修_合肥厂房无尘室设计_合肥工厂洁净工程装修公司-安徽盛世和居装饰 | 西安标准厂房_陕西工业厂房_西咸新区独栋厂房_长信科技产业园官方网站 | 对照品_中药对照品_标准品_对照药材_「格利普」高纯中药标准品厂家-成都格利普生物科技有限公司 澳门精准正版免费大全,2025新澳门全年免费,新澳天天开奖免费资料大全最新,新澳2025今晚开奖资料,新澳马今天最快最新图库 | 礼仪庆典公司,礼仪策划公司,庆典公司,演出公司,演艺公司,年会酒会,生日寿宴,动工仪式,开工仪式,奠基典礼,商务会议,竣工落成,乔迁揭牌,签约启动-东莞市开门红文化传媒有限公司 | 创客匠人-让IP变现不走弯路 | 马尔表面粗糙度仪-MAHR-T500Hommel-Mitutoyo粗糙度仪-笃挚仪器 | 电位器_轻触开关_USB连接器_广东精密龙电子科技有限公司 | 电动百叶窗,开窗器,电动遮阳百叶,电动开窗机生产厂家-徐州鑫友工控科技发展有限公司 | 密集架-手摇-智能-移动-价格_内蒙古档案密集架生产厂家 | 茅茅虫AI论文写作助手-免费AIGC论文查重_写毕业论文降重 | 河南mpp电力管_mpp电力管生产厂家_mpp电力电缆保护管价格 - 河南晨翀实业 | 热处理温控箱,热处理控制箱厂家-吴江市兴达电热设备厂 | 东莞喷砂机-喷砂机-喷砂机配件-喷砂器材-喷砂加工-东莞市协帆喷砂机械设备有限公司 | 卫生纸复卷机|抽纸机|卫生纸加工设备|做卫生纸机器|小型卫生纸加工需要什么设备|卫生纸机器设备多少钱一台|许昌恒源纸品机械有限公司 | 骨密度仪-骨密度测定仪-超声骨密度仪-骨龄测定仪-天津开发区圣鸿医疗器械有限公司 | 消防设施操作员考试报名时间,报名入口,报考条件 | 福建珂朗雅装饰材料有限公司「官方网站」 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 液压升降平台_剪叉式液压/导轨式升降机_传菜机定做「宁波日腾升降机厂家」 | 双舌接地线-PC68数字式高阻计-ZC36|苏海百科 | 铁艺,仿竹,竹节,护栏,围栏,篱笆,栅栏,栏杆,护栏网,网围栏,厂家 - 河北稳重金属丝网制品有限公司 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 电销卡_北京电销卡_包月电话卡-豪付网络 | 管理会计网-PCMA初级管理会计,中级管理会计考试网站 | 大行程影像测量仪-探针型影像测量仪-增强型影像测量仪|首丰百科 大通天成企业资质代办_承装修试电力设施许可证_增值电信业务经营许可证_无人机运营合格证_广播电视节目制作许可证 | HEYL硬度计量泵-荧光法在线溶解氧仪-净时测控技术(上海)有限公司 | 储气罐,真空罐,缓冲罐,隔膜气压罐厂家批发价格,空压机储气罐规格型号-上海申容压力容器集团有限公司 | 砂尘试验箱_淋雨试验房_冰水冲击试验箱_IPX9K淋雨试验箱_广州岳信试验设备有限公司 | 专业生物有机肥造粒机,粉状有机肥生产线,槽式翻堆机厂家-郑州华之强重工科技有限公司 | 冰晶石|碱性嫩黄闪蒸干燥机-有机垃圾烘干设备-草酸钙盘式干燥机-常州市宝康干燥 | 经济师考试_2025中级经济师报名时间_报名入口_考试时间_华课网校经济师培训网站 | 便携式谷丙转氨酶检测仪|华图生物科技百科 | 【星耀裂变】_企微SCRM_任务宝_视频号分销裂变_企业微信裂变增长_私域流量_裂变营销 | 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | 网架支座@球铰支座@钢结构支座@成品支座厂家@万向滑动支座_桥兴工程橡胶有限公司 | 硅胶布|电磁炉垫片|特氟龙胶带-江苏浩天复合材料有限公司 | 天然鹅卵石滤料厂家-锰砂滤料-石英砂滤料-巩义东枫净水 |