Reputation: 319
insert into class_pre_req(class_id, cpr_id) values(select class_id from classes where catlg_nbr = 265 and subject_id = 27, select class_id from classes where catlg_nbr = 166 and subject_id = 27);
I am trying into insert into this table with the values as insert statements. I assume I am just using the wrong syntax. Any help please?
Upvotes: 0
Views: 45
Reputation: 521289
VALUES
is only used when inserting literal records. Instead, just insert a select statement consisting of two subqueries:
INSERT INTO class_pre_req (class_id, cpr_id)
SELECT
(SELECT class_id FROM classes WHERE catlg_nbr = 265 AND subject_id = 27),
(SELECT class_id FROM classes WHERE catlg_nbr = 166 AND subject_id = 27);
Note that in order for this to work, each subquery would have to return a single value.
Upvotes: 1