我有一個查詢爲什麼這個SQL不起作用?
public static function TestQuery(
$start=0,
$limit=0){
$sql = "
SELECT count(*) AS total
FROM db.table1
JOIN db.table2
ON table1.fieldID = {$fieldID}
AND table2.assigned = 'N'";
$qry = new SQLQuery;
$qry->query($sql);
if($row = $qry->fetchRow()){
$total = intval($row->total);
}
return $total;
}
工作正常,但是當我添加了極限之下,則它不工作,並給了我錯誤
public static function TestQuery(
$start=0,
$limit=0){
$sql = "
SELECT count(*) AS total
FROM db.table1
JOIN db.table2
ON table1.fieldID = {$fieldID}
AND table2.assigned = 'N'";
//this fails
if($recordlimit > 0) $sql .= "LIMIT {$startRecord}, {$recordLimit} ";
//
$qry = new SQLQuery;
$qry->query($sql);
if($row = $qry->fetchRow()){
$total = intval($row->total);
}
return $total;
}
任何幫助將不勝感激
爲什麼會不會有沒有空間的錯誤? – 2010-04-20 18:53:04
WHERE字段上的Mysql錯誤='N'LIMIT ... – webbiedave 2010-04-20 18:57:36
@webbiedave:不適合我。你使用的是什麼版本的MySQL? – 2010-04-20 18:58:52