我有这样的错误:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\lab\try.php on line 40
查询是:
$graphquery = mysql_query ("SELECT
$cluster,
SUM(IF(idx=3,1,0)) AS green,
SUM(IF(idx=2,1,0)) AS yellow,
SUM(IF(idx=1,1,0)) AS red
FROM (SELECT
$cluster
$xcond
,LEAST(999 $acond) idx
FROM table
WHERE date >= '". $startDate ."'
AND date <= '". $endDate ."'
AND $regional = '$gregcond'
AND $latitude IS NOT NULL
GROUP BY $cluster, $lac, $mainid
HAVING $cluster IS NOT NULL
$paraxcond
) A
GROUP BY $cluster");
如果我回显查询,它将是这样的(没有错误,顺便说一句,结果也很完美):
SELECT
cluster,
SUM(IF(idx=3,1,0)) AS green,
SUM(IF(idx=2,1,0)) AS yellow,
SUM(IF(idx=1,1,0)) AS red
FROM (SELECT
cluster,
ROUND(AVG(some_value_Index)) some_value_Index,
LEAST(999, AVG(some_value_Index) ) idx
FROM TABLE
WHERE tanggal >= '2012-07-10'
AND tanggal <= '2012-08-02'
AND Regional = 'Regional_Example'
AND Latitude IS NOT NULL
GROUP BY cluster, Lac, ID
HAVING cluster IS NOT NULL
AND some_value_Index IN(3,2,1)) A
GROUP BY cluster
当我在该脚本上添加 mysql_error 时,听起来像这样:
Incorrect parameter count in the call to native function 'LEAST'
以下是我愿意使用 MYSQL 查询的方式:
$row = mysql_fetch_array ($graphquery)
当我 ECHO 查询并在 SQLYOG 或 PHPMYADMIN 上尝试时,没有包含错误,所以谁能告诉我错误在哪里?