作者:诚实宝贝2002 | 来源:互联网 | 2023-05-18 09:30
WhenwritingviewsandnestingviewswithindeeperviewsIsometimesmisssomethingandenduplosin
When writing views and nesting views within deeper views I sometimes miss something and end up losing rows/data. How can I check that columns from two different tables have an exact match of data?
当我在更深入的视图中编写视图和嵌套视图时,我有时会丢失一些东西,最终会丢失行/数据。如何检查来自两个不同表的列是否具有精确的数据匹配?
Example:
例子:
select count(distinct table1.col1)
from table1
where table1.col1 not in (select distinct table2.col1
from table2);
This would return the number of values in table1.col1 that are not in table2. However, I don't know that this is a good solution as it doesn't count the table2.col1 values that do not exist in table1.col1.
这将返回表1中值的数量。col1不在表2中。然而,我不知道这是一个好的解决方案,因为它不包括表2。表1.col1中不存在的col1值。
4 个解决方案