Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex SQL Statement
Message
 
 
To
08/05/2009 11:41:52
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01398646
Message ID:
01398650
Views:
63
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform