代碼: 選擇全部
SELECT pts_name
FROM products_tecspecs
WHERE pts_id IN ( 5275, 21, 5276, 5277,
5278, 49, 5279 )
ORDER BY FIELD(pts_id, 5275, 21, 5276, 5277, 5278, 49, 5279)
FIELD 及 刮號中間不能有空白
代碼: 選擇全部
SELECT pts_name
FROM products_tecspecs
WHERE pts_id IN ( 5275, 21, 5276, 5277,
5278, 49, 5279 )
ORDER BY FIELD(pts_id, 5275, 21, 5276, 5277, 5278, 49, 5279)
代碼: 選擇全部
$query = str_replace("'","",$this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)));//去掉'
$query = substr($query,0,-10);//去掉 LIMIT
$query .= " ORDER BY FIELD(student_no,".$_GET['s_class_student_no'].")";//加上依輸入資料排序
echo $query;
//$this->query($this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)));
$this->query($query);