Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SPT Syntax
Message
 
To
26/05/2011 10:38:54
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP1
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01511825
Message ID:
01511860
Views:
34
>I am back with another SPT issue. I have the following SQL to get the latest date from a set of related tables but I need the record index number and table that actually produces the result.
>
>
>
>testconnString = "Select MAX(iDate) As iDate From (Select MAX(idate) As iDate From webprddt7.qms8dprevn Where edindex = 870871 And editeratn = 2" +;
>" Union All Select MAX(idate) As iDate From webprddt7.qms8dcntrl Where edindex = 870871 And editeratn = 2" +;
>" Union All Select MAX(idate) As iDate From webprddt7.qms8dvers1 Where edindex = 870871 And editeratn = 2" +;
>" Union All Select MAX(idate) As iDate From webprddt7.qms8dpca Where edindex = 870871 And editeratn = 2" +;
>" Union All Select MAX(idate) As iDate From webprddt7.qms8dica Where edindex = 870871 And editeratn = 2) td"
>
>
Use TEXT ENDTEXT in VFP when you build your string.
That will make your code more readable.
TEXT TO testconnString  NOSHOW
Select MAX(iDate) As iDate 
From (Select MAX(idate) As iDate From webprddt7.qms8dprevn Where edindex = 870871 And editeratn = 2
      Union All
      Select MAX(idate) As iDate From webprddt7.qms8dcntrl Where edindex = 870871 And editeratn = 2
      Union All
      Select MAX(idate) As iDate From webprddt7.qms8dvers1 Where edindex = 870871 And editeratn = 2
      Union All 
      Select MAX(idate) As iDate From webprddt7.qms8dpca   Where edindex = 870871 And editeratn = 2
      Union All
      Select MAX(idate) As iDate From webprddt7.qms8dica   Where edindex = 870871 And editeratn = 2) td
ENDTEXT 
About your request, what if you have the same date in several tables?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform