SQL:如何在更新语句中自引用列?
我有两个包含这些列的表:
用户: 用户、班级、年级、位置。
课程: 类、位置
用户表的类列引用类表中的同一列。
我想更新用户表中的所有行,以便用户表的“位置”列的每一行都等于类的位置。
所以我有一行值: Mike,数学,A+,纽约
数学班级表中的相应行是: 数学,芝加哥
我希望用户表的行变成 迈克,数学,A+,芝加哥。
谢谢
I have two tables with these columns:
Users:
user, class, grade, location.
Classes:
class, location
The class column of the Users table references the same colmn in Classes table.
I want to update all rows in the Users table such that each row of the Users table's "location" column is equal to the location of the class.
So i have a row with values:
Mike, Math, A+, New York
And the corresponding row in Classes table for Math is:
Math, Chicago
I want the user table's row to become
Mike, Math, A+, Chicago.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个怎么样:
How about this: