【问题标题】:Query Issue in sqlsql中的查询问题
【发布时间】:2012-11-19 17:38:48
【问题描述】:

我无法执行这个查询

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);  

【问题讨论】:

  • 只能猜测您想要查询的目的,但 user_id=2699478 之后的逗号是问题所在,可能是 AND 或 OR??

标签: sql oracle


【解决方案1】:

您必须将两个条件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
    ) 

【讨论】:

    【解决方案2】:

    尝试将逗号替换为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】:

      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);
      

      【讨论】:

        【解决方案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);  
        

        【讨论】:

          猜你喜欢
          • 2013-11-08
          • 2011-11-07
          • 2023-04-01
          • 1970-01-01
          • 1970-01-01
          • 2010-12-20
          相关资源
          最近更新 更多