I am trying to update a column of a table with values of another table's column, depending on the values of the updated column in SQlite. Here is an example:
Table 1
A
1
2
3
1
3
4
Table 2
A B
1 x
2 x
3 y
4 y
Result Table 1 after query:
A
x
x
y
x
y
y
From related questions, I tried the following queries:
update Table1 set A=(select B from Table2 where(A=Table2.A))
This fills col A of Table 1 with all x.
Also, another version I found here did not work, as it threw the error "no such columns: table2.B":
update Table1 set A=Table2.B where(A=Table2.A)
Any help is highly appreciated!
Aucun commentaire:
Enregistrer un commentaire