由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Mathematics版 - SQL check likeness between two large tables (转载)
相关主题
SQL combine two tables into one table and add a new column (转载)Error of SQL query on IBM netezza SQL database from Aginity (转载)
a problem that bugs me for quite a whileError of SQL query on IBM netezza SQL database from Aginity (转载)
Yau likes smart guys,和YAU走的远的就没聪明人Error of SQL query on IBM netezza SQL database from Aginity workbench
问个问题,不知如何很好的解决。请教一个sql问题
SQL check likeness between two large tables (转载)SQL Server query 一问
SQL check likeness between two large tables (转载)SQL combine two tables into one table and add a new column
SQL check likeness between two large tablesSQL combine two tables into one table and add a new column (转载)
SQL combine two tables into one table and add a new column2009年12月9号-最新版务声明
相关话题的讨论汇总
话题: table2话题: sql话题: table1话题: rows话题: tables
进入Mathematics版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Statistics 讨论区 】
发信人: light009 (light009), 信区: Statistics
标 题: SQL check likeness between two large tables
发信站: BBS 未名空间站 (Tue May 6 15:38:29 2014, 美东)
I need to check the likeness between two data tables on SQL. I am working on
Aginity Workbench for Netezza on Win 7.
The tables are very large. One of them has 100 million rows and 4 columns;
another one has 1500 million rows and 3 columns.
Example, table1
ID1 ID2 ID3 Value
xxxx xxxxxx xxxxxxxx xxx.xxxxxx // here x is 0-9 int
table2:
ID1 ID2 Value
xxxx xxxxxx xxx.xxxxxx
the ID1 and ID2 may be duplicated but Values are not duplicated in the same
table.
I need to check whether table1 is a subset of table2 and find the rows that
are avaialble in table1 but not in table2 and vice versa.
I am new to SQL. How to design the efficient SQL queries ? I need to do the
same tasks frequently, so en efficient query may be more helpful.
I use this method :
SELECT * FROM table1 a
WHERE NOT EXISTS (
SELECT table2.ID1
FROM table2 b
WHERE b.ID1 = a.ID1
AND b.ID2 = a.ID2)
But, the results are 0 rows. I also checked that there are no duplicated
rows in the two tables. Why table2 is much larger than table1 ?
Are there other ways to find their differences ?
Thanks
r*g
发帖数: 3159
2
SELECT *
FROM table1 LEFT OUTER JOIN table2
ON table1.ID1 = table2.ID1 AND table1.ID2 = table2.ID2
WHERE table2.ID1 IS NULL
OR table2.ID2 IS NULL
S*********N
发帖数: 6151
3

从他问的几个问题看,他根本没系统学过数据库和算法,自学了几个语法来解决
自己的问题。

【在 r*g 的大作中提到】
: SELECT *
: FROM table1 LEFT OUTER JOIN table2
: ON table1.ID1 = table2.ID1 AND table1.ID2 = table2.ID2
: WHERE table2.ID1 IS NULL
: OR table2.ID2 IS NULL

1 (共1页)
进入Mathematics版参与讨论
相关主题
2009年12月9号-最新版务声明SQL check likeness between two large tables (转载)
少林寺外,蓝螃蟹向麻油兔挑战: mayoutu,你怎么会有将近4万块钱的炒股钱的SQL check likeness between two large tables (转载)
增加赌博种类SQL check likeness between two large tables
天籁之音隆重推出【我永远的童年】六一活动SQL combine two tables into one table and add a new column
SQL combine two tables into one table and add a new column (转载)Error of SQL query on IBM netezza SQL database from Aginity (转载)
a problem that bugs me for quite a whileError of SQL query on IBM netezza SQL database from Aginity (转载)
Yau likes smart guys,和YAU走的远的就没聪明人Error of SQL query on IBM netezza SQL database from Aginity workbench
问个问题,不知如何很好的解决。请教一个sql问题
相关话题的讨论汇总
话题: table2话题: sql话题: table1话题: rows话题: tables