首页 > 解决方案 > 查询在本地主机上运行良好;但是,不在 Web 服务器上运行 - 出现错误(SELECT 将检查超过 MAX_JOIN_SIZE 行)

问题描述

我在我的 sql 查询中使用多个连接。他们在我的本地主机上运行良好。但是,一旦我将我的 PHP 网站上传到我的 ipage 网络托管服务器上。我网站上的 mysqli 查询停止工作。我收到以下错误:

#1104 - The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay

我在这里阅读了一些可以追溯到 2009 年至 2013 年的旧线程;其中谈到了对连接中包含的列进行索引。作为结论,我能够在 Phpmyadmin 中运行查询。但是,它对网站本身没有帮助。我无法使用 mysqli 查询通过它自己的网页获取记录。

我的查询示例:

<?php
require_once "../config.php";
$state = htmlspecialchars($_GET['state']);


if($state != ""){
        
     $sql=" SELECT 
            item.*,
            sku.*,
            pricing.*,
            shipping.*
        
        
            FROM sku
            INNER JOIN item
            ON SUBSTRING(sku.item_id,2,8) = SUBSTRING(item.item_id,1,8)
            
            LEFT JOIN pricing
            ON sku.sku_code = pricing.sku_code
                
            LEFT JOIN shipping
            ON sku.sku_code = shipping.sku_code
            
            WHERE item.name = ? AND sku.sku_code = ? AND sku.sku_add = ?;
        
        
        ";
        
            if($stmt = $mysqli->prepare($sql)){
                // Bind variables to the prepared statement as parameters
                $stmt->bind_param("sss", $param_a,$param_b,$param_c);
                
                // Set parameters
                $param_a = $_REQUEST["name"];
                $param_b = $_REQUEST["sku_code"];
                $param_c = $_REQUEST["sku_add"];
                
                
                // Attempt to execute the prepared statement
                if($stmt->execute()){
                    $result = $stmt->get_result();
                    
                    // Check number of rows in the result set
                    if($result->num_rows > 0){
                        // Fetch result rows as an associative array
                        while($row = $result->fetch_array(MYSQLI_ASSOC)){
                 
                                
                                $name = $row['name'];
                                $size = $row['size'];
                                $color = $row['color'];
                                $price = $row['price'];
                                /*and so on...*/
                                
                        }
                    } else{
                        
                        exit;
                    }
                }
             
            // Close statement
            $stmt->close();
            }
        // Close connection
        $mysqli->close();
        }
?>

           <input name="name" id="name" type="text" value="<?php echo $name; ?>">
           <input name="size" id="size" type="text" value="<?php echo $size; ?>">
           <input name="color" id="color" type="text" value="<?php echo $color; ?>">
           
           <!--and so on...-->

标签: phpmysql

解决方案


推荐阅读