I have a table with 5 columns (name, record, un, svun, svrecord):
| Name | idrecord | un | svun | svrecord |
|---|---|---|---|---|
| John Doe | JD123 | johndoe | NULL | JM123 |
| Jane Doe | JaD123 | janedoe | NULL | OR123 |
| Olive Err | OR123 | oliverr | NULL | GH123 |
I'm trying to populate the svun column with the value from the idrecord column when the svrecord matches an idrecord from another row.
For instance, row #2 should update the svun column to OR123 because the svrecord (OR123) matches the idrecord (OR123) from the table. Hope this makes sense.
I've started trying to come up with a query for this below but can't quite figure it out...I'm sure i'm missing a parameter to make this work or maybe an additional select statement...:
UPDATE table
SET svun = idrecord
WHERE (svrecord = idrecord)