ORDER BY FIELD not working

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

ORDER BY FIELD not working

文章 yehlu »

http://stackoverflow.com/questions/1156 ... or-message

代碼: 選擇全部

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) 

ORDER BY FIELD(
FIELD 及 刮號中間不能有空白
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: ORDER BY FIELD not working

文章 yehlu »

ccs4 modify

代碼: 選擇全部

$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);
回覆文章

回到「MySQL」