Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Not getting all of the possible records?
Message
 
 
À
25/10/2002 17:24:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00715045
Message ID:
00715699
Vues:
11
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform