lzzyqxxh
2016-02-02 07:22
采纳率: 33.3%
浏览 2.3k

oracle的“不满足”某个条件该怎么写

比如,我想写一个语句
insert into t1(t1.a,t1.b)
select (t2.a,t2.b) from t2 “不满足”
(t2.a=t1.a and t2.b=t1.b);
以上,求大神解惑。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • Yiran8935 2016-02-02 07:37
    已采纳

    参照下这个
    insert into student(sname,sage) select t2.cname,t2.cid from course t2 where not exists
    (select 1 from student t1 where t1.sname = t2.cname and t1.sage = t2.cid);

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • threenewbee 2016-02-02 07:28

    insert into t1(t1.a,t1.b)
    select (t2.a,t2.b) from t2 not(t2.a=t1.a and t2.b=t1.b);
    或者
    insert into t1(t1.a,t1.b)
    select (t2.a,t2.b) from t2 not(t2.a=t1.a) or not (t2.b=t1.b);

    评论
    解决 无用
    打赏 举报
  • Yiran8935 2016-02-02 07:54

    create table student(
    sname varchar2(10) not null,
    sage number(3)
    );

    create table course(
    cname varchar2(10) not null,
    cid number(3)
    );

    insert into student values('YES',14);
    insert into student values('YES',13);
    commit;

    insert into course values('YES',13);
    commit;

    select * from course;
    select * from student;

    insert into student(sname,sage) select t2.cname,t2.cid from course t2 where not exists
    (select 1 from student t1 where t1.sname = t2.cname and t1.sage = t2.cid);

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题