Oracle 根据另一个表中的值进行更新
我有两个表 ROOMS 和 LEASE,如下所述,
create table ROOMS (ROOM_NUM number, FLOOR varchar2(50))
create table LEASE (ROOM_NUM number, RENT_RATE number(4,2))
我想将 ROOMS 表中具有 FLOOR='Carpet' 的所有房间的 LEASE 表中的租金率设置为 3.50。
我看过很多例子,但似乎无法想出解决方案。
我意识到我没有创建 ROOM_NUM 主键或外键,但我只是使用 3 条记录来解决测试问题,并确保它们的房间号存在于两个表中
I have two tables ROOMS and LEASE as described below
create table ROOMS (ROOM_NUM number, FLOOR varchar2(50))
create table LEASE (ROOM_NUM number, RENT_RATE number(4,2))
I want to set the rent_rate in the LEASE table to 3.50 for all rooms that have FLOOR='Carpet' in the ROOMS table.
I have looked at MANY examples but cannot seem to come up with a solution.
I realize that I didn't make ROOM_NUM primary or foreign keys but I am just using 3 records for a test problem and have ensured that they room numbers exist in both tables
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
希望有帮助。
Hope that helps.
而且,如果您需要创建行而不是更新现有行:
And, if you need to create the rows rather than updating existing rows: