Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Not Working
Message
De
20/02/2013 11:02:59
 
 
À
20/02/2013 10:15:08
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01566476
Message ID:
01566494
Vues:
44
>>I am using the following SQL to Delete the Data in Table New_master. IF all the fields of New_master Matches With the Master.DBF the row should be deleted.
>>
>>My SQL is not working, please suggest the required SQL.
>>
>>MY SQL is as Follows
>>
>>
>>DELETE FROM New_Master WHERE Accountno In (Select Accountno Number FROM Master WHERE ;
>>New_master.Phoneno= Master.Phoneno AND New_master.Exchange= Master.Exchange AND ;
>>New_master.firstname= Master.firstname AND ;
>>New_master.lastname=ALLTRIM(Master.Lastname))
>>
>>
>>Kinldy Provide The SQL for The above Task
>>
>>Regards
>If you write it a little diffent it is easier to debug.
>
>DELETE NM ;
>FROM New_Master NM 
>WHERE NM.AccountNo IN ( ;
>                       SELECT T.AccountNo ;
>                       FROM Master T ;
>                       WHERE NM.PhoneNo = T.PhoneNo ;
>                          AND NM.Exchange = T.Exchange ;
>                          AND NM.FirstName= T.FirstName ;
>                          AND NM.LastName = ALLTRIM(T.LastName) ;
>                       ) 
>
>Now it's easy to highlight the subquery, rightclick Execute Selection, and see that it knows nothing of NM.
>
>DELETE NM ;
>FROM New_Master NM 
>WHERE NM.AccountNo IN ( ;
>                       SELECT T.AccountNo ;
>                       FROM Master T ;
>                       JOIN New_Master N ;
>                       ON NM.PhoneNo = T.PhoneNo ;
>                          AND NM.Exchange = T.Exchange ;
>                          AND NM.FirstName= T.FirstName ;
>                          AND NM.LastName = ALLTRIM(T.LastName) ;
>                       ) 
>
>Now you can test the subquery.
>Finally the ALLTRIM here is not what you want unless you want a "Smith" to join up with "Smithson".

Right. My rule of thumb is to avoid Alltrim unless you really, REALLY need it. I have seen many cases where alltrim breaks the code, and few where it fixes things.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform