我必须以这种方式订购我的数据:
1)获取Country=Belgium;
2)使用Country=United Kingdom
;
3)获取Country=France
;
4)按字母顺序获取所有其他行。
目前我按字母顺序排序:
SELECT * FROM (SELECT * FROM table ORDER BY Name) table";
if (isset($_POST['search'])){
$search_term=mysql_real_escape_string($_POST['search_box']);
$sql .="WHERE Name LIKE '%{$search_term}%' ";
$sql .=" OR Mission LIKE '%{$search_term}%'";
如何将比利时,英国和法国的这些排在前面? 谢谢!
答案 0 :(得分:2)
order by
case Country -- or is it Name ?
when 'Belgium' then 0
when 'United Kingdom' then 1
when 'France' then 2
else 3
end,
Name