First I am using mySQL.
(ID) [category] {step}
before
(1) [1] {1}
(2) [2] {1}
(3) [2] {2}
(4) [2] {2}
(5) [3] {3}
I have the above data in myTable
I like to modify all records which has direct or indirect relation with the category value "2".
The records should be updated in the step fields by
by the step value from step into step+1.
The target data would be the following.
(1) [1] {1}
(2) [2] {2}
(3) [2] {3}
(4) [2] {3}
(5) [3] {4}
please notice the category value [3] of the record (5) has the same name of
record (3) which has its category value [2]. this means record (5) has indirect
relation with category value [2]
update myTable
set step=step+1
where category=2
the above code will produce the following result.
(ID) [category] {step}
(1) [1] {1}
(2) [2] {2}
(3) [2] {3}
(4) [2] {3}
(5) [3] {3}
The step value of the record (5) is not changed to "4".
This is the reason why I try to use JOIN.
How can I change it from "3" to "4"?