Take a look at my table:
id | les_mo_id | les_comp | les_ch_comp
.1.|...................|........0....... |...................
.2.|........1..........|.................|.........1.........
.3.|........1..........|.................|.........1.........
.4.|...................|........0....... |...................
.5.|........4..........|.................|.........2.........
.6.|........4..........|.................|.........1.........
.7.|...................|........0........|...................
.8.|........7..........|.................|.........1.........
.9.|........7..........|.................|.........4.........
I'm struggling to figure out how to set up a query to update the 'les_comp' column in line with my new learning progress.
The task involves updating the columns 'les_comp' by calculating the sum of 'les_ch_comp' values where les_mo_id = 1.
This is the SQL query I've come up with so far:
UPDATE base_app SET les_comp = (SELECT SUM(les_ch_comp) WHERE les_mo_id = "1") WHERE id = "1";