I tried to update a column in a specific table which has a parent table. The table is gradings
and the column in this table whose value I want to update is sy_id.
The other table school_years
has column sy_id
and sy_dates
which having a value. 2018 -2019, 2019 - 2020....
I want to update the column sy_id
in gradings
but I have no idea how to solve the error.
UPDATE gradings
INNER JOIN school_years
ON gradings.sy_id = school_years.sy_dates
INNER JOIN students
ON gradings.student_id = students.id
SET gradings.sy_id = '2017 - 2018'
WHERE students.id = 1;
Any thoughts?
Assuming that you are not joining on the wrong columns, this should work fine:
update gradings g,
school_years sy,
students s
set
g.sy_id = '2017 - 2018'
where
g.student_id = s.id
and g.sy_id = sy.sy_dates
and s.id = 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.