在sql中查询问题

时间:2012-06-20 15:47:59

标签: sql oracle

我无法执行此查询获取

  

ORA-00933:SQL命令未正确结束
  00933. 00000 - “SQL命令未正确结束”

select count(user_id) 
from t_user 
where user_id = 2699478, object_id = 1329 
  and user_id not in
      (SELECT owner_user_id FROM t_obj where actual_id = 17447);  

4 个答案:

答案 0 :(得分:5)

您必须使用适当的条件运算符替换两个条件,之间的逗号user_id=2699478 ,object_id=1329,并使用括号以您希望的方式表达它们,如下所示:

SELECT COUNT(user_id) 
FROM t_user 
WHERE user_id = 2699478 
  AND object_id = 1329 
  AND user_id NOT IN
    (
        SELECT owner_user_id 
        FROM t_obj 
        WHERE actual_id = 17447
    ) 

答案 1 :(得分:4)

尝试将逗号替换为AND

select count(user_id) from t_user where user_id=2699478 AND object_id=1329 and user_id not in
  (SELECT owner_user_id FROM t_obj where actual_id = 17447);

答案 2 :(得分:3)

and替换逗号:

select count(user_id)
from t_user
where user_id=2699478
  and object_id=1329
  and user_id not in (SELECT owner_user_id FROM t_obj where actual_id = 17447);

答案 3 :(得分:1)

您需要用“AND”替换逗号:

SELECT count(user_id) FROM t_user WHERE user_id=2699478 AND object_id=1329 AND user_id NOT IN
      (SELECT owner_user_id FROM t_obj WHERE actual_id = 17447);