0
表更新列CLASS (class, count)
SQL UPDATE - 兩個表 - 具有取決於列的增量值在另一個表
class count
--------- -------
first 3
second 2
third 4
表STUDENT (class, id_no, name)
name id_no name
-------- ------- ------
first 1 abc
first 2 bcd
first 3 def
second 1 xyz
second 2 tay
third 1 m
third 2 n
third 3 o
third 4 p
在STUDENT
表中的行的總數始終是等於計入CLASS
表中。 例如:CLASS
表中的第一個條目將類名稱顯示爲「第一個」並計爲3. 因此它將在STUDENT
表中具有3個條目。
現在的問題是 - 學生表的id_no
列在所有行中都爲零。
它應該更新如上所示。
如何實現?