Reputation: 22270
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?
Upvotes: 0
Views: 164
Reputation: 107816
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
Upvotes: 2