Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting exact record match between datasets
Message
De
08/09/2005 12:45:46
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
08/09/2005 12:34:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01047673
Message ID:
01047762
Vues:
7
>>>Hi Jay
>>>
>>>>In the SQL below, I'm using TransHist.iTransact to determine whether I want a result record or not. What I really need is to know if the exact record does not exist in TransHist, not just by using the iTransact field value. The same fields exist in the crsTestAcctContiUniCont cursor and the TransHist table. How would I do this?
>>>>
>>>>
>>>>
>>>>SELECT * ;
>>>>	FROM crsTestAcctContiUniCont;
>>>>	WHERE crsTestAcctContiUniCont.iTransact NOT IN (SELECT iTransact FROM TransHist) ;
>>>>	INTO CURSOR crsUpdate
>>>>
>>>
>>>
>>>If I'm reading you right, this will give all crsTestAcctContiUniCont records that have a match in TransHist (using the iTransact) but differ in any one of the other fields. It will also union in all the crsTestAcctContiUniCont records that have no match in TransHist. If I remember correctly the ORs will stop processing as soon as any one of them is true.
>>>
>>>
>>>select ;
>>>    TA.* ;
>>>  from ;
>>>    crsTestAcctContiUniCont TA ;
>>>  inner join ;
>>>    TransHist TH ON ;
>>>      TA.iTransact = TH.iTransact ;
>>>      AND (TA.Field1 # TH.Field1 ;
>>>       OR TA.Field2 # TH.Field2 ;
>>>       OR TA.Field3 # TH.Field3 ... ) ;
>>>union ;
>>>  select ;
>>>    TA.* ;
>>>  from ;
>>>    crsTestAcctContiUniCont TA ;
>>>  where ;
>>>    TA.iTransact NOT IN (SELECT TH.iTransact FROM TransHist TH)
>>>
>>
>>Mike,
>>Unfortunately OR/AND doesn't stop in SQL (hope I'm wrong and ith has changed). A "join on ..." is likely to C...5 with too many fields to compare.
>>Cetin
>
>It change in VFP9

Fabio,
Are you sure?
CLEAR
CREATE CURSOR test1 (v1 i)
CREATE CURSOR test2 (v1 i)
FOR ix=1 TO 5
	INSERT INTO test1 VALUES (m.ix)
	INSERT INTO test2 VALUES (m.ix)
ENDFOR

SELECT * ;
 FROM test1 t1 ;
  left JOIN test2 t2 ON (t1.v1 = t2.v1 OR udf())
 
FUNCTION udf
? "Should never be called"
PS: Correction
SELECT * ;
FROM test1 t1 ;
left JOIN test2 t2 ON (t1.v1 = t2.v1 OR udf(t1.v1,t2.v1))

FUNCTION udf
LPARAMETERS tn1,tn2
? tn1,tn2

It's called once while it shouldn't.

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform