I am using a query to select price from price column without dollar and then order by that alias after if statement. But order by that alias name is not working.
Query which I am using is
SELECT
*,
IF( SUBSTRING( price , '1', '1' ) = '$',
round( replace( price , '$', '' ) ) ,
price ) AS coupon
FROM ccs_product
WHERE (product_name LIKE '%JoyLot.com%'
OR website_name LIKE '%JoyLot.com%'
OR description LIKE '%JoyLot.com%')
ORDER BY coupon ASC
LIMIT 0 , 10;
解决方案
use this query its works use round(price)
SELECT
*,
IF( SUBSTRING( price , '1', '1' ) = '$',
round( replace( price , '$', '' ) ) ,
round(price) ) AS coupon
FROM ccs_product
WHERE (product_name LIKE '%JoyLot.com%'
OR website_name LIKE '%JoyLot.com%'
OR description LIKE '%JoyLot.com%')
ORDER BY coupon ASC
LIMIT 0 , 10;