medk medk - 1 year ago 90
SQL Question

mySQLi Select number when contains white space

How to select from table where price is >= 3000 when the field type is string and the numbers are formatted as: 3 000, 20 000, 5 000...

'SELECT * FROM products WHERE price >= 3000'

Is there a way to format it on the fly to remove the space and keep the results output as the original?

Answer Source
SELECT * FROM `products` WHERE REPLACE(price, ' ', '') > 5000

But you should really change the type of your column.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download