2013-07-22 149 views
-4

我在SQL ORDER函數中遇到問題。我的產品數據庫包含圖片和價格。我想要的就是這樣訂購我的結果是:所有產品的圖像價格從低到高顯示,然後我的產品沒有圖像顯示價格從低到高。在MySQL中排序結果

任何幫助,將不勝感激。

UPDATE: 這裏是我的表結構:

id - brand - code - name - type - pile_weight - size - pcs_ctn - sf_ctn - lbs_ctn - picture - description - color_code - manufacturer - supplier - pricing_unit - total_wgt - retail_price - sale_price - dealer_price - featured 

以下是我已經儘可能的查詢都要做到:

SELECT * FROM products ORDER BY picture, retail_price 
SELECT * FROM products ORDER BY picture DESC, retail_price ASC 
SELECT * FROM products ORDER BY CASE WHEN picture = '' THEN 1 ELSE 0 END, picture, retail_price ASC 
+1

請將您當前的查詢,並表明你試圖解決的問題。 – atk

+1

要獲得答案,您至少應該描述您的表格結構 – valex

+1

嘗試添加ORDER BY img_column,price_column其中img_column – DeiForm

回答

1

你應該清楚地提到你的表的設計。我仍可以發佈您的解決方案這個sqlfiddle http://sqlfiddle.com/#!2/eb8f7/2

select * from table1 order by ifnull(image,0) ,price asc