sql: how can I copy the value from a table into another?
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
精彩评论