MySQL TO_NUMBER Alternative: CAST & CONVERT

There is no TO_NUMBER function in MySQL like there is in Oracle, but you can use the CAST or CONVERT function to convert a value to a numeric type. Here’s an example:

SELECT CAST('123' AS SIGNED) AS num;

In the example above, we convert the string ‘123’ to a signed integer type and name it “num”. You can also use the CONVERT function to perform similar operations.

SELECT CONVERT('123', SIGNED) AS num;

These functions can assist you in converting a value to a numerical type in MySQL.

bannerAds