MAX_JOIN_SIZE行; SET SQL_BIG_SELECTS = 1 - 脚本在2年后停止工作

时间:2017-05-21 11:08:00

标签: php mysql select

Exception -> string(69) "SQLSTATE[HY000]: General error: 1193 Unknown system variable 'OPTION'" Exception -> string(202) "SQLSTATE[42000]: Syntax error or
 access violation: 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" Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 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' in 
/customers/e/3/b/jkr.no/httpd.www/STS/amob/inc/timer.php:295 Stack trace: #0 
/customers/e/3/b/jkr.no/httpd.www/STS/amob/inc/timer.php(295): unknown() #1 /customers/e/3/b/jkr.no/httpd.www/STS/amob/index.php(542): 
include('/customers/e/3/...') #2 {main} thrown in /customers/e/3/b/jkr.no/httpd.www/STS/amob/inc/timer.php on line 295

此脚本已正常工作2年。我在活动表中删除了超过2000行,也许它太大了?

SQL-问题

$hsql = "SELECT h.ID, h.ukeID, h.normal, h.natt, h.FP, h.HP, h.datumID, h.status, h.orderID, 
h.tilleggID, h.yearID, u.ID as userID, u.level as ulevel, 
u.navn as fnavn, u.etternavn, t.navn as tnavn, o.ID as oID, o.navn as onavn,
 o.pH as opH, o.pB as opB, o.pR as opR, o.pS as opS, o.pP as opP, o.pLE as opLE 
FROM timesheet h LEFT JOIN user u ON u.ID = h.userID LEFT JOIN orders o ON
 o.ordernr = h.orderID LEFT JOIN tillegg t ON t.tilleggnr = h.tilleggID AND 
t.orderID = o.ID".$hsql.$sstr.$yearID."  ORDER BY userID ASC, yearID DESC, ukeID DESC, datumID DESC";

第295行

foreach($hstmt as $hrow) {

1 个答案:

答案 0 :(得分:0)

切换

SET OPTION SQL_BIG_SELECTS=1

SET SESSION SQL_BIG_SELECTS=1

现在有效!