MySQL Script Snippets For WordPress Hosting D phpMyAdmin

Order by Number when numbers are stored as strings

Select * From table ORDER BY CAST(price AS DECIMAL(10,2)) DESC

Reference:  https://stackoverflow.com/questions/8887760/order-by-price-returns-a-weird-order-in-mysql

 

Facebook Comments