Using Oracle SQL, I am trying to insert into table A based on select from table B, but I am not sure how to achieve this, since the select is returning more than one row.
INSERT INTO A
VALUES
(
SELECT id FROM B WHERE status = 'APPROVED',
'Hardcoded-Value'
);
Table B:
id | status |
---|---|
1 | APPROVED |
2 | DECLINED |
3 | APPROVED |
Based on that insert, I want to achieve following: Table A:
Column A | Column B |
---|---|
1 | Hardcoded-Value |
3 | Hardcoded-Value |
CodePudding user response:
You can use a const in the select list
INSERT INTO A(colA, colB)
SELECT id, 'Hardcoded-Value'
FROM B
WHERE status = 'APPROVED'