【发布时间】:2013-07-22 13:31:31
【问题描述】:
我在使用 SQL ORDER 函数时遇到问题。我的产品数据库有图片和价格。我想要的是像这样订购我的结果:所有产品的图片显示价格从低到高,然后我的产品没有图片显示价格从低到高。
任何帮助将不胜感激。
更新: 这是我的表结构:
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
【问题讨论】:
-
请添加您当前的查询,并证明您已尝试解决问题。
-
要获得答案,您至少应该描述您的表格结构
-
尝试添加ORDER BY img_column, price_column where img_column
-
order by img = '' desc, price asc