当前位置: 代码迷 >> 其他数据库 >> not and 的逻辑不对吗?该怎么解决
  详细解决方案

not and 的逻辑不对吗?该怎么解决

热度:131   发布时间:2016-05-05 08:16:09.0
not and 的逻辑不对吗?
本帖最后由 u014766963 于 2014-06-04 17:07:02 编辑
sqlite3  e:\\test.db
create table t1(f1 TEXT,f2 TEXT,f3 integer);
create table t2(f1 TEXT,f2 TEXT);
insert into t1 values("x1","y1",9);
insert into t1 values("x1","y1",8);
insert into t1 values("x1","y1",3);
insert into t1 values("x1","y2",9);
insert into t1 values("x1","y3",9);
insert into t1 values("x1","y4",9);
insert into t1 values("x1","y2",7);
insert into t2 values("x1","y1");
insert into t2 values("x1","y2");

1.为何使用 

select t1.* from t1,t2 where not(t1.f1=t2.f1 and t1.f2=t2.f2) ;
不能得到结果
"x1","y3",9
"x1","y4",9

2.如何使用delete from 得到结果?


delect from t1(select t1.*  from t1,t2 where t1.f1 =t2.f1 and t1.f2=t2.f2) ;  这句话如何修改,才能得到上面的结果?
------解决思路----------------------
楼主的逻辑好乱.想一下,t1表有7条记录,t2表有2条记录,组合起来共有14条记录,一条一条用楼主的条件检测一下吧.
要实现此要求请查一下 exists 的用法吧
  相关解决方案