开发者

sql: how can I copy the value from a table into another?

开发者 https://www.devze.com 2023-02-05 12:16 出处:网络
I have a table PLANE_MODEL: PLANE_MODEL(NUMBER model_id, NUMBER capacity) and a table FLIGHT: FLIGHT ( NUMBER flight_id,NUMBER available_seats)

I have a table PLANE_MODEL:

PLANE_MODEL(NUMBER model_id, NUMBER capacity)

and a table FLIGHT:

FLIGHT ( NUMBER flight_id,NUMBER available_seats)

I want to copy the value capacity of PLANE_MODEL开发者_开发技巧 as the initial value in available_seats of FLIGHT. How can I do this?


To create a FLIGHT record for a particular flight (1234) using a model (918), you can use the below

insert into FLIGHT ( flight_id, available_seats )
SELECT 1234, capacity
FROM PLANE_MODEL
WHERE model_id = 918
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号