+ -
当前位置:首页 → 问答吧 → 数据库的问题,在线等;

数据库的问题,在线等;

时间:2011-12-16

来源:互联网

selcet target from r_c_e_h20111205 t where call_type='1' not in (selcet call_number from d_areacfg);
请问下这句话有什么错误。这句话就是说在r_c里面找在d_里面没有的数据;

作者: wuzhentian   发布时间: 2011-12-16

少了and,并且改用exists
SQL code
selcet target from r_c_e_h20111205 t 
where call_type='1' and not exists (selcet call_number from d_areacfg);

作者: yixilan   发布时间: 2011-12-16

该回复于2011-12-16 16:31:22被管理员删除

  • 对我有用[0]
  • 丢个板砖[0]
  • 引用
  • 举报
  • 管理
  • TOP
#3楼 得分:0回复于:2011-12-16 16:26:37

 where call_type='1' and xxxx not in (selcet call_number from d_areacfg);

作者: hfhf111   发布时间: 2011-12-16

引用 3 楼 lxpbs8851 的回复:
where call_type='1' and xxxx not in (selcet call_number from d_areacfg);

3楼的也对。
如果用not in,前面就必须加上字段名;
如果用not exists,前面不用加字段名、

作者: lxpbs8851   发布时间: 2011-12-16

引用 4 楼 yixilan 的回复:
引用 3 楼 lxpbs8851 的回复:
where call_type='1' and xxxx not in (selcet call_number from d_areacfg);

3楼的也对。
如果用not in,前面就必须加上字段名;
如果用not exists,前面不用加字段名、


偶感觉关键是楼主少了个字段名,就是用哪个字段的值与d_areacfg中比较呢。如果按1楼的写法是不符合楼主需求的,合用exists也需要加上where条件才对。

作者: yixilan   发布时间: 2011-12-16

正解
引用 3 楼 lxpbs8851 的回复:
where call_type='1' and xxxx not in (selcet call_number from d_areacfg);

作者: xiaobn_cn   发布时间: 2011-12-16

热门下载

更多