我在使用 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