简体   繁体   中英

Oracle INSERT multiple rows

My statement will insert two out of the four student IDs. The ones that are inserted are Id's that already exist with another section number. I cant figure out why the other two are not inserted.

INSERT INTO enrollment
    (student_id,section_id,enroll_date,created_by,created_date,modified_by,modified_date)
SELECT
    student_id,'48',SYSDATE,'KABEL',SYSDATE,'KABEL',SYSDATE
FROM enrollment
WHERE student_id IN ('375','137','266','382');

There is nothing much wrong in your query. You are typo or by mistake choose INSERT table and SELECT query from one table as this does not make any sense, to select from one table and insert into same table.

Your select and Insert statement using the same table enrollment .

These should be two different table.

INSERT INTO enrollment <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-------Here Problem
  (student_id,section_id,enroll_date,created_by,created_date,
      modified_by,modified_date)
SELECT
    student_id,'48',SYSDATE,'KABEL',SYSDATE,'KABEL',SYSDATE
FROM enrollment   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-------Here Problem
WHERE student_id IN ('375','137','266','382');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM