I'm working with Postgres 9.1 and I have added a new boolean column to my table:
ALTER TABLE frontend_item ADD COLUMN is_generic BOOLEAN;
The value of this column will be based on the value of another column, code. If characters 10-11 of code are AA then the value of is_generic should be TRUE. Otherwise it should be false (or null if it hasn't been set yet).
My question, is how can I do this in Postgres? I've been able to work out some individual components using the docs:
UPDATE frontend_item SET is_generic...
And then I know I can get the substring of code as follows:
substring(code from 10 for 2)
But how do I turn substring into a boolean, and then glue it together with the UPDATE statement?