cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert char to num MYSQL database

former_member672670
Participant
0 Kudos

Hey Guys,

I have an object in the Universe Design Tool 4.0 which has "Character" data type. I need to convert it into a measure/number. The database is MySQL. Can anyone tell me the formula to convert it? Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try with the SQL below and update if you face any issues

To separate text and number from string like  USA-200  use the below query

SELECT field,CONVERT(SUBSTRING_INDEX(field,'-',-1),UNSIGNED INTEGER) AS num
FROM table

Just to convert a numeric fields stored in number use

SELECT field,CONVERT(field,UNSIGNED INTEGER) AS Number
FROM table

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can use either CAST or Convert to change the datatypes.

CAST(field as INT)

Thanks

Gaurav