如何按特定方式订购?

时间:2016-03-22 13:58:31

标签: php mysql sql

Mysql表:

id | category    | image<br>
--------------------------------
0  | landscape   | image name
1  | panarimic   | image name
2  | portrait    | image name
3  | landscape   | image name
4  | landscape   | image name
5  | portait     | image name

我想编写mysql select,它应首先获取格局,而不是列出其他格局。我怎样才能做到这一点?我可以添加类别编号并制作“按顺序排列”,但没有它可以采用另一种方法吗?

2 个答案:

答案 0 :(得分:5)

是的,您可以在using System.IO.Compression; namespace CustomZip { class Program { static void Main(string[] args) { string startPath = @"c:\example\start"; string zipPath = @"c:\example\result.rjb"; string extractPath = @"c:\example\extract"; ZipFile.CreateFromDirectory(startPath, zipPath); ZipFile.ExtractToDirectory(zipPath, extractPath); } } } 中使用CASE EXPRESSION

ORDER BY CLAUSE

答案 1 :(得分:0)

SELECT 
  * 
FROM
  tableName 
ORDER BY 
  CASE
    WHEN category LIKE 'landscape' 
    THEN 1 
    ELSE 0 
  END DESC ;