select * from table1 where f1 not in (select a.f1 from table1 a inner join table2 b on a.f1=b.f1)
这个也可以哦 select * from table1 where (f1 not in table2) and/or (f2 not in table2)看看你的实际情况,是该用and还是or
select * from table1 where table1.fl not in (select table2.fl from table2.fl)
select * from table1 where not exists(select field1 from table1 a join b table on a.id=b.id)
这题好难!!!!! select * from table1 where f1 not in (select g1 from table1 join table2 on table1.f1=table2.g1)
其实,他这么问法并不难,如果加一个限制条件就难了:只用连接的形式实现,而且table2里还要有条件的 比如如何用连接实现如下语句: select * from t1 where id1 not in(select id2 from t2 where id3=:var) 这就是我10天前问的问题,可以说这个问题的答案就不好找了 我已经想出了一个几乎完美的答案: select a.* from t1 a,t2 b where id1 not in(select id2 from t2 where id3=b.id3) and b.id3=:var
select * from table1 A where not exists (select 1 from table2 B where A.列1=B.列1 and A.列2=B.列2...)
dqxhyyyy() : 你的问题也不难。select t1.* from t1 left join t2 on t1.f1=t2.f1 where t2.f2 = :var and t1.f1 is null 就是查找左连接后 t1表中对应列为空值的那些记录。
select * from table1 where (f1 not in table2) and/or (f2 not in table2)看看你的实际情况,是该用and还是or
select * from table1 where f1 not in
(select g1 from table1 join table2 on table1.f1=table2.g1)
比如如何用连接实现如下语句:
select * from t1 where id1 not in(select id2 from t2 where id3=:var)
这就是我10天前问的问题,可以说这个问题的答案就不好找了
我已经想出了一个几乎完美的答案:
select a.* from t1 a,t2 b where id1 not in(select id2 from t2 where id3=b.id3)
and b.id3=:var
你的问题也不难。select t1.* from t1 left join t2 on t1.f1=t2.f1
where t2.f2 = :var and t1.f1 is null 就是查找左连接后 t1表中对应列为空值的那些记录。