表记录是
tag enabled
paypal 1
bank 1
creditcard 1
COD 1
我的查询是
$sql = "SELECT * FROM payment_type WHERE enabled = '1'";
$result = mysql_query($sql);
while($data = mysql_fetch_assoc($result)) {
echo $data['tag'];
}
由于某些原因,我想把信用卡显示为最后一个值。提前谢谢。
答案 0 :(得分:1)
使用case
制作单独的排序顺序
SELECT * FROM payment_type
WHERE enabled = '1'
order by case when tag = 'creditcard'
then 1
else 2
end
答案 1 :(得分:1)
试试这个:请参阅 DEMO
$sql = "SELECT * FROM payment_type WHERE enabled = '1'
Order By case when tag <> 'creditcard' then 0 else 1 end;"