MySQL Forums
Forum List  »  UDF

Function in order by clause problem
Posted by: Michel DOMINIQUE
Date: September 25, 2015 07:45AM


I'm struggling with function. I created a function which return TEXT string. I tried to use it in order by clause by it doesn't work.
The function is deterministic and called version_sort.
After creating the function, if I do
'select version_name from version order by version_sort("version_name", "desc")'
the result is not what expected. However if I get the TEXT returned by the function using 'select version_sort("version_name", "desc") from version limit 1'
and then replace the result in the first query, it's OK:

select version_name from version order by
CONVERT(SUBSTRING_INDEX(version_name,".",1), signed) desc,CONVERT(REPLACE(SUBSTRING_INDEX(version_name,".",2),CONCAT(SUBSTRING_INDEX(version_name,".",1),"."),""), signed) desc,CONVERT(REPLACE(SUBSTRING_INDEX(version_name,".",3),CONCAT(SUBSTRING_INDEX(version_name,".",2),"."),""), signed) desc,LOCATE(" ",version_name) asc,LENGTH(version_name) desc,version_name desc,CONVERT(REPLACE(SUBSTRING_INDEX(version_name,".",4),CONCAT(SUBSTRING_INDEX(version_name,".",3),"."),""), signed) desc

Is it possible to use function in 'order by' clause ?

Thanks for help

Options: ReplyQuote

Written By
Function in order by clause problem
September 25, 2015 07:45AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.