php - 查询在本地主机上运行良好;但是,不在 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...-->
解决方案
推荐阅读
- python - 将 url 修改为 pandas 中的列
- r - 关于 R 中未加权 ANES 调查的问题
- spring - 如果使用 Spring 不存在复合键,如何将文档插入 MongoDB
- javascript - 如何限制在 JavaScript 中的按钮上添加的文件数量?
- swift - 为什么在 flatMap 中调用 Completable 方法不起作用?
- reactjs - 构建 create-react-app 后,网格区域不适用于 1 行
- dialogflow-es - 限制或处理用户在对话流中提出的查询
- c# - System.Text.Json 不序列化列表
- javascript - 循环遍历对象数组,根据日期是否在当前月份进行过滤
- python - 一起使用加密和股票 OHLCV 数据。如何处理非交易缺口以避免指数和指标问题?