我不是 SQL 专家,因此需要您的帮助。
我有这个由其他人编写的高级查询:
SELECT cms_product_bid.*,
cms_products.*,
cms_products_images.pd_image,
cms_products_images.pd_image_label,
IF (cms_product_bid.pd_bid = 1,
IF(cms_product_bid.pd_bid_start_date <= CURDATE(),
IF(cms_product_bid.pd_bid_end_date >= CURDATE(),1,0)
,0)
,1) AS bid_product_check
FROM cms_products
LEFT JOIN cms_products_images
ON (cms_products.pd_id = cms_products_images.pd_id)
INNER JOIN cms_product_bid
ON (cms_product_bid.product_id = cms_products.pd_id)
INNER JOIN cms_home_product_slider
ON (cms_products.pd_id = cms_home_product_slider.pd_id)
WHERE cms_products.pd_status=1
AND cms_products.pd_visibility=1
AND cms_home_product_slider.cat_id='$featured_cat_id'
GROUP BY cms_products.pd_id
HAVING(bid_product_check =1)
ORDER BY cms_products.pd_sort ASC
我要做的只是排序,cms_products.pd_sort
但它不是按该列排序,即使表中的列具有诸如 等的1
值2
。
谁能在这里指出这个问题?