I using sqlite and have a table that looks like:
I am trying to update refer column with values from col2 corresponding col1
I tried query like
update tab1
set refer = (select col2 from tab1 where col1 = refer)
where col1 = 2
This but is not working.
I have also tried
update tab1
set refer = (select tem1.col2
from tab1 tem1, tab1 tem2
where tem1.col1 = tem2.refer and tem2.col1=2)
where col1 = 2
This works.
But I am not sure whether this is the correct way to do.