andandandand
andandandand

Reputation: 22270

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?

Upvotes: 0

Views: 164

Answers (1)

RichardTheKiwi
RichardTheKiwi

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

Related Questions