I have a mysql query
SELECT jss_products . * , jss_extrafields_values.content as test_weight
FROM jss_products_tree
INNER JOIN jss_products ON jss_products.productID = jss_products_tree.productID
INNER JOIN jss_extrafields_values ON jss_extrafields_values.productID = jss_products.productID AND extraFieldID = 5
WHERE sectionID = 1
ORDER by test_weight
It returns me different products with their options and other things, as well as their weight. Now the thing about weight, it is a varchar field. And currently weight is not only an integer, but it can be anything like
18.8 Gram
20 Gram
20g
18.5gr
18.5g
18.5 gr
Style 4 18 gram
Style B 18gram
1081A 22gram
1081B 22 gr
16 gram Knurled (k)
and similar.
Basicly what all have in common, the weight might be lets say 10-40gram. most of the time it's double digit number but it might be decimal as well.
Now what I need to do, is to sort products by weight. I was trying regexp, abs, cast and other functions which returns the field as integer but none of them worked as expected.
Any thoughts on this? What should I use? Is it even possible to do it? Please do ask if I could provide more information. Thanks.