Why is my SQL failing? (ORA-00933: SQL command not properly ended)

别说谁变了你拦得住时间么 提交于 2019-12-13 05:19:25

问题


Why is my SQL failing? I think it s formatted correctly, but it throws an error at me.

    INSERT INTO NBOT_USERS
       (ID,LAST_NAME,FIRST_NAME)
    VALUES
       (1002, 'Smith', 'John')
    WHERE 1002 NOT IN (SELECT IT_ID FROM NBOT_USERS);

回答1:


Inserting Values with a Subquery: Example

INSERT INTO bonuses
   SELECT employee_id, salary*1.1 
   FROM employees
   WHERE commission_pct > 0.25 * salary;

With your schema:

INSERT INTO NBOT_USERS (ID,LAST_NAME,FIRST_NAME)
Select 1002, 'Smith', 'John' 
  From dual
  WHERE 1002 NOT IN (SELECT  FROM NBOT_USERS);



回答2:


Insert queries do not have where clauses, unless you're doing INSERT ... SELECT FROM, in which case there can be a where clause in the SELECT portion.



来源:https://stackoverflow.com/questions/8156931/why-is-my-sql-failing-ora-00933-sql-command-not-properly-ended

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!