0
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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.