var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Help to Postgres 8.4
I have at table containing several columns. One column (A) is of type (character varying, 18) containing numbers as for instance "7813406". All are containing 7 numbers and no decimals!
I have in the same table a column of type ‘Integer’ also containing numbers for instance 7813999.
How do I convert column (A) to type ‘Integer’. I want to compare columns (A) and (B).
In the end I want to update the table when column (A) contains a value not found in column (B)
Column (B) is more often known!!
Korsgaard – Denmark.
Sorry for my poor English
Will display all rows where both columns have the same value.
WHERE column_a = column_b::varchar
More details about type conversion can be found in the manual:
PostgreSQL: Documentation: Manuals: PostgreSQL 8.4: Type Conversion
Shammat. Thanks a lot.
That was the solution of my converting problem.
How do you go the opposite way (from varchar to Integer)?
Originally Posted by korsgaard
or if you want to be more portable (i.e. compatible with other DBMS)
Here is a more detailed description of this: PostgreSQL: Documentation: Manuals: PostgreSQL 8.4: Value Expressions
cast(varchar_column AS integer)
But the other direction (varchar -> integer) might fail if there are non-numeric characters...
Why do you store numbers in character columns anyway?
It is almost always a very bad idea!
Postgres 8.4 - converting
Database has been designed in this way. So sorry about that!!
Thanks for your help. I can now compare the two columns.