I have a PostgreSQL table in which some of the rows are dirty because at point of data entry the gender
of the record is "unknown" although it always stays the same indicated by its object_id
, which is the unique identifier of the object.
object_id gender
511E1AC7128EE2E74349896B55461F27 Unknown
511E1AC7128EE2E74349896B55461F27 Unknown
511E1AC7128EE2E74349896B55461F27 Male
56665EA256AB3757CDFA6C1CB4334C91 Female
56665EA256AB3757CDFA6C1CB4334C91 Female
56665EA256AB3757CDFA6C1CB4334C91 Unknown
56665EA256AB3757CDFA6C1CB4334C91 Unknown
55C3BFDBD327396E912604D6E635D59B Unknown
55C3BFDBD327396E912604D6E635D59B Unknown
55C3BFDBD327396E912604D6E635D59B Female
Therefore, I want to update my table to be like this:
object_id gender
511E1AC7128EE2E74349896B55461F27 Male
511E1AC7128EE2E74349896B55461F27 Male
511E1AC7128EE2E74349896B55461F27 Male
56665EA256AB3757CDFA6C1CB4334C91 Female
56665EA256AB3757CDFA6C1CB4334C91 Female
56665EA256AB3757CDFA6C1CB4334C91 Female
56665EA256AB3757CDFA6C1CB4334C91 Female
55C3BFDBD327396E912604D6E635D59B Female
55C3BFDBD327396E912604D6E635D59B Female
55C3BFDBD327396E912604D6E635D59B Female
In which all the "unknown" columns are converted to whatever non-unknown value the object_id
has in /some other entry/. Is there a way I can do this in PostgreSQL - or - even better - Sequelize (Javascript ORM for SQL databases?)