2012-02-28 104 views
1

我想从表中检索具有image_typepriority等字段的记录。使用SQL查询检索记录

property id image_type priority 
1   1   1 
1   0   1 
1   1   2 
1   0   2 
1   0   3 

我想告诉像所有的图像类型Records唱片公司走到一起&按照优先顺序或者ASCDESC安排。

+0

灿你显示你想看到的输出? – 2012-02-28 09:23:43

回答

1
SELECT 
    * 
FROM 
    undefined_table_name 
GROUP BY 
    image_type 
ORDER BY 
    image_type ASC; 
0

使用ORDER BY

SELECT `property id`, `image_type`, `priority` 
FROM `your_table` 
ORDER BY `image_type`, `priority` DESC 
0

你希望他们通过priority(ASC)排序,然后按image_type(DESC),所以你会做这样的:

SELECT `property id`, `image_type`, `priority` 
FROM `your_table` 
ORDER BY `priority`, `image_type` DESC