[英]Select Negation of one table from another along with data in master table sql query for oracle
I am stuck with an issue. 我陷入一个问题。 I have 3 tables in my oracle database.
我的oracle数据库中有3个表。 First table contains all registered employees: ID, FNAME, LNAME Second table contains all employees(Registered + Unregistered): - ID, FNAME, LNAME Third table is a master table having all details of employee along with address.
第一个表包含所有已注册员工:ID,FNAME,LNAME第二个表包含所有员工(已注册+未注册):-ID,FNAME,LNAME第三个表是一个主表,其中包含员工的所有详细信息以及地址。 ID is common in all 3 tables.
ID在所有3个表中都是通用的。
Here my requriment is to write a query which will display all not registered employees with there address details. 在这里,我的要求是编写一个查询,该查询将显示所有未注册的员工以及地址详细信息。
Some ID's are null as well in all tables which have to be neglected. 在所有必须忽略的表中,某些ID也为null。
Table 1 - Registered Users Table 2 - Registered+Not Registered Table 3 - Master Table which contains additional information 表1-注册用户表2-注册+未注册表3-主表包含其他信息
Requirement:- Select ID, Name, Address for not registered users. 要求:-为未注册用户选择ID,名称,地址。
Query will be more helpful instead of explanation. 查询将比解释更有用。
Thanks, 谢谢,
I think not exists
or not in
does what you want: 我认为
not exists
或not in
你想要做什么:
select m.*
from masters m
where not exists (select 1
from registered r
where r.id = m.id
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.