postgres convert text to number
SELECT ' 5800.79 '::INTEGER;
postgres convert text to number
SELECT ' 5800.79 '::INTEGER;
postgres convert number to string
Because the number can be up to 15 digits, you'll need to cast to an 64 bit (8-byte) integer. Try this:
SELECT * FROM table
WHERE myint = mytext::int8
The :: cast operator is historical but convenient. Postgres also conforms to the SQL standard syntax
myint = cast ( mytext as int8)
If you have literal text you want to compare with an int, cast the int to text:
SELECT * FROM table
WHERE myint::varchar(255) = mytext
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us