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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select records from table A not exist in tabe B 1

Status
Not open for further replies.

R17

Programmer
Jan 20, 2003
267
PH

hello!

how do you select records from table A that does not exist in table B?

i use SQL command like :

SELECT * FROM XA A WHERE NOT EXISTS (SELECT checkno FROM XM B WHERE a.checkno=b.checkno .AND. a.agycode=b.agycode .AND. a.brcode=b.brcode)

that works well but it is taking too long, like more than 5 mins.

both tables have the same structure, each has more than 50,000 records. im using foxpro for windows 2.6 on a win 98.

any help?

 
SELECT * FROM XA WHERE CHECKNO NOT IN (SELECT CHECKNO FROM XM)

That should give you every checkno that does not exist in XM.


Rob.
 
If you need to check all 3 variables:

SELECT * FROM XM WHERE CHECKNO+AGYCODE+BRCODE NOT IN ( SELECT CHECKNO+AGYCODE+BRCODE FROM XM )

or if checkno, agycode,brcode are numbers place the str(variable, length) function around each numerical variable.

Rob
 
And of course the first XM in the last example should be XA.

Rob.
 
To create difference two files, try
sele b
index on checkno+agycode+brcode tag klic
sele a
set rela to checkno+agycode+brcode into b
copy to differ for eof("b")
go top
... and measure time ...
Tesar
 

hey rob44 thanks a lot!!! great help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top