如何在sql中编写查询以将每位教师的薪水更新为给定以下架构的10,000倍于他们所教课程的数量?
这是数据库的架构:
答案 0 :(得分:0)
查询:
UPDATE instructor
SET salary = 10000 *
(SELECT COUNT(*) FROM section s
JOIN teaches t ON s.sec_id = t.sec_id
JOIN instructor i ON t.id = i.id
WHERE i.id = instructor.id);