MySQL:“SELECT 将检查超过 MAX_JOIN_SIZE 行";
我正在使用 PHP 和 MySQL.在我的程序中有一个涉及连接的选择查询.当我在本地主机上运行它时它工作正常但是当我将它上传到我的服务器并尝试执行它时它会产生以下错误:
SELECT 将检查超过 MAX_JOIN_SIZE 行;检查您的 WHERE 并使用 SET SQL_BIG_SELECTS=1 或 SET SQL_MAX_JOIN_SIZE=# 如果 SELECT 没问题
我该如何纠正?
解决方案使用 PHP 时,SQL_BIG_SELECTS=1 应该在主查询之前在单独的查询中设置.例如:
$mysqli = new mysqli("localhost", "root", "password", "db");$mysqli->query("SET SQL_BIG_SELECTS=1");//在你的主查询之前设置它$results = $mysqli->query("SELECT a, b, c FROM test");while($row = $results->fetch_assoc()){echo '';print_r ($row);echo '</pre>';}
I am using PHP and MySQL. In my program there is a select query involving joins. When I run it on localhost it's working fine but when I upload it on my server and try to execute it then it generates the following error:
The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
How can I correct this?
解决方案When using PHP, SQL_BIG_SELECTS=1 should be set in a separate query before your main query. For example:
$mysqli = new mysqli("localhost", "root", "password", "db");
$mysqli->query("SET SQL_BIG_SELECTS=1"); //Set it before your main query
$results = $mysqli->query("SELECT a, b, c FROM test");
while($row = $results->fetch_assoc()){
echo '<pre>';
print_r ($row);
echo '</pre>';
}
相关文章