Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query - help

Status
Not open for further replies.

jodugg

Programmer
Jun 22, 2004
9
US
Simple question for the guru's...

2 tables:
table_a – 8mm records
table_b – 1mm records

They each have the same table structure. I need to create a table with every row in table_a that is NOT in table_b.

Since each row (all columns) acts as the “key” I’m selecting all fields concatenated together…unfortunately the hash_aj hint will not work this way. My query has been running for like 11 hrs!

What's a better option?
Thanks in advance.
 

Try MINUS:
Code:
Create TAble New_Table
As
Select * From Table_A MINUS Select * From Table_B;
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
YOu could also use a union query, union only adds distinct records

Create TAble New_Table
As
Select * From Table_A
Union
Select * From Table_B;


Ian
 
Ian,

The query you post results in all distinct rows from both tables.

LK's query does as JoDugg specifies: "...every row in table_a that is NOT in table_b".

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top