MySQL Executing string as math operation -
in column have this:
amount:
12 2x25 192 how possible multiply in example 2x25 order correctly asc.
my starting point:
select * table order replace(amount,'x','*') asc tia frgtv10
try this
select cast(if(amount '%x%', substring_index(amount, 'x', 1) * substring_index(amount, 'x', -1) , amount) unsigned ) amount table1 order amount asc steps , explaining :
locate fields x value
sbstring left , right , multiply it.
then cast multiplication unsigned.
order asc
Comments
Post a Comment