[英]how to select all records from one table that not exist in relation table?
ObjectClass1对象类 1
OBID | Name
0001 | ob01
0002 | ob02
Relation1关系1
RELID|LEFTOBID|RIGHTOBID|CLASS1|CLASS2
R001 |0001 |000X |ObjectClass1|ObjectClass2
Now What I want to find out is how to write a query to find out that relation does not exists for OBID 0002现在我想知道的是如何编写查询以找出 OBID 0002 不存在关系
Use not exists
as :使用not exists
为:
select *
from ObjectClass1 o
where not exists
( select 1 from Relation1 r where r.LEFTOBID = o.OBID );
SQL
SELECT *
FROM ObjectClass1 obj
LEFT JOIN
Relation1 rel
on obj.OBID = rel.LEFTOBID
WHERE rel.LEFTOBID is null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.