简体   繁体   English

选择一个表与另一个表的否定以及oracle主表sql查询中的数据

[英]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 existsnot 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.

相关问题 从一个表中选择,插入到另一个表中 oracle sql 查询 - select from one table, insert into another table oracle sql query ORACLE SQL-从一个表中选择SELECT并在另一个表中添加条件 - ORACLE SQL - SELECT SUM from One Table With Conditions in Another Table 将数据与其他值一起从一个表传输到另一个表(SQL) - Transfer data from one table to another along with other values (SQL) 如何选择主表数据并选择referance表顶部的一个数据sql查询 - How to Select master table data and select referance table top one data sql query 从多个表中选择,然后插入另一个表中的Oracle SQL查询 - Select from multiple tables, insert into another table Oracle SQL query 查询问题:是否有更好的方法从一个表中选择所有记录,以及从另一表中选择不匹配的记录? - Query question: Is there a better way to select all records from one table, along with unmatched records from another table? 从一个表返回数据以及从另一个表映射数据的SQL最佳方法 - SQL Best way to return data from one table along with mapped data from another table 使用连接查询(oracle sql)时如何查看一个表中的所有数据并在另一个表上过滤 - How to see all data from one table and filtered on another, when using a join query (oracle sql) Oracle - SQL 查询根据列值将数据从一个表分装到另一个表? - Oracle - SQL query to bin the data from one table to another based on a column value? 具有来自另一个表的数据和字段匹配的Oracle SQL UPDATE查询 - Oracle SQL UPDATE query with data and field matching from another table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM