Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Not getting all of the possible records?
Message
 
 
To
25/10/2002 17:24:13
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00715045
Message ID:
00715699
Views:
10
This message has been marked as the solution to the initial question of the thread.
Hi Gordon,

It's always tricky with VFP because of limited support for correlated quiries and subquieries in general. Try this
SELECT Str(id) + MAX(TTOC(effective_date, 1)) AS id_maxdt;
	FROM address_tbl ;
	INTO CURSOR crsAddr

SELECT Str(id) + MAX(TTOC(effective_date, 1)) AS id_maxdt ;
	FROM name_tbl ;
	INTO CURSOR crsName

SELECT id.*, NVL(nm.lname, ' ') lname ;
	FROM id_table id ;
		LEFT JOIN name_tbl nm 	ON id.id = nm.id ;
		LEFT JOIN address_tbl ad ON id.id = ad.id ;
	WHERE (nm.effective_date IS NULL ;
		OR Str(nm.id) + TTOC(nm.effective_date, 1) IN ;
			(SELECT id_maxdt FROM crsName)) ;
		AND (ad.effective_date IS NULL ;
			OR Str(ad.id) + TTOC(ad.effective_date,1) IN ;
				(SELECT id_maxdt FROM crsAddr)) 
>I tried your solution and got back an error "SQL expression is too complex." I even simplified the query down for testing purposes:
>
>SELECT a.*, b.nameinfo...
>FROM id a LEFT JOIN names b
>ON a.id = b.id
>WHERE (b.id IS NULL OR TTOC(b.effective_date, 1) =
>(SELECT MAX(TTOC(f.effective_date, 1)) FROM names f WHERE f.id = b.id))
>
>I am not sure what is too complex for VFP ;-) This is exactly what I was looking for but I don't know why it doesn't work.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform