Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One Works, One Doesn't
Message
From
27/06/2006 08:34:54
 
 
To
26/06/2006 16:49:12
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 2003 Server
Miscellaneous
Thread ID:
01131819
Message ID:
01131937
Views:
18
This pulls all inactive records in untype and the matching records in incilog as it should:

lcSelect = "SELECT " ;
+" * " ;
+" FROM Table1 a LEFT OUTER JOIN Table2 b on LTRIM(RTRIM(a.unitcode)) = LTRIM(RTRIM(b.unitcode))" ;
+" AND LTRIM(RTRIM(a.unittype)) = LTRIM(RTRIM(b.usertyped))" ;
+" WHERE a.inactive = 'TRUE' and EXISTS ( SELECT * FROM untype WHERE inactive = 'TRUE' ) ";
+" ORDER BY a.unitcode, a.unittype, b.timestamp DESC "

However, my goal now is to pull all records in Table1 that have inactive = 'true' (whether or not there is a matching record in Tabl2) but only pull the top 5 matching records in Table2 by timestamp descending (the 5 most recent records in Table2) for each record pulled in Table1 (if any matching records exist in Table2). I am stumped this morning, ideas?
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform