Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex SQL Statement
Message
 
 
À
08/05/2009 11:41:52
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01398646
Message ID:
01398650
Vues:
64
>Need help with SPT SQL statement.
>
>I need a column in my SQL that gets a value based on one of the fields in the main SQL but I need the column to pull by wild card(LIKE) something like the following, which does not work)
>
>
>
>testString = "Select webprddt6.drawmext3.dmdrawno As f1, prevchng, dwgshts, projengd," +;
>" webprddt6.drawmext3.dmcust, jobno1, dm_drawing_title," +;
>" (Select itnbr From amflib6.itemasa Where itnbr Like f1" + '%' + ") f2 From webprddt6.drawmext3" +;
>" Join webprddt6.drawmstrp On webprddt6.drawmstrp.dm_drawing_number = webprddt6.drawmext3.dmdrawno" +;
>" Where projengd = '05/06/2009' Order By webprddt6.drawmext3.dmdrawno"
>
>
I believe you need an inner join where you can have LIKE clause of join. Otherwise I would use either table valued or scalar function (SQL Server).
Select webprddt6.drawmext3.dmdrawno As f1, prevchng, dwgshts, projengd," +;
>" webprddt6.drawmext3.dmcust, jobno1, dm_drawing_title, itnbr as F2 " +;
>" From webprddt6.drawmext3" +;
>" Join webprddt6.drawmstrp On webprddt6.drawmstrp.dm_drawing_number = webprddt6.drawmext3.dmdrawno" +;
" JOIN amflib6.itemasa ON itnbr Likewebprddt6.drawmext3.dmdrawno " + '%'" + ;
>" Where projengd = '05/06/2009' Order By webprddt6.drawmext3.dmdrawno "
Also please use TEXT -ENDTEXT - the code would be much easier to read/test/modify.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform