I need to extract an integer in this string. How would I do this using MySQL or PostgreSQL?
user_id='12345'
In this string I must get the number 12345.
I need to extract an integer in this string. How would I do this using MySQL or PostgreSQL?
user_id='12345'
In this string I must get the number 12345.
You would use the CAST function.
SELECT CAST(user_id AS INT) FROM Table
Reference: http://dev.mysql.com/doc/refman/5.5/en/cast-functions.html#function_cast
Besides the standard SQL syntax demonstrated by @Daniel Li, there is also the PostgreSQL specific shorthand:
user_id::int
The manual will happily tell you about this really basic stuff ...