Sorting on two price fields in MySQL was a confusing thought at first, and was tempted to query then use php to do it. No!
I needed a way to select my products and order them by price. But we have two prices, a “price” and “price_offer”, so we need to compare these values so we can get our results sorted just how we need them…
$q = "SELECT id FROM product_variations
WHERE product_id = ‘$product_id’
AND active = ‘1’
WHEN price_offer < price
easy when you know how!