mysql - compatibility Query for to_number() -


in query using to_number() in oracle. how write compatibility query oracle , mysql databases.

select col1 table condition order to_number(col2); 

here col2 varchar2 datatype. suppose used order by command in query must use converting function i.e to_number(col2),this function not available in mysql.so please give correct solution above problem

create custom function in mysql db name to_number takes same parameter , returns integer .
can use cast function inside custom function

delimiter $$
drop function if exists to_number$$
create function to_number (number varchar(10)) returns int (11)
begin
return (cast(number signed));
end$$
delimiter ;
create custom/userdefined function to_number name
can use query both in oracle , mysql


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -