I have a table where column sub is first digit from column id.
id | sub |
---------+-------+
21 | 2 |
32 | 3 |
43 | 4 |
I want to create a trigger that updates sub when id is changed.
Below is an example of the result I want:
id | sub |
---------+-------+
21 | 2 |
22 | 2 |
43 | 4 |
In the second row, the value for id has changed from '32' to '22', so the sub must change from '3' to '2'.
Can someone please help me solve my problem?