Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Puzzle
Message
 
 
To
28/11/2003 12:20:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00854130
Message ID:
00854256
Views:
21
>Sergey,
>
>SQL 1 returns records that should not be in the file. The total returned should be 14 as SQL 2 statement would then duplicate each for Asia and Africa. I suspect the reason is you will find more than one record with the same genus and species if the same continent, but a different site. (Please bear with me, this is my daughter's data.)
>
Hi Ken,

Try this one.
SELECT genus, species, continent ;
	FROM species JOIN site ON species.pkey = site.fkey ;
	WHERE site.continent = 'Asia' ;
		AND genus + species IN ( ;
			SELECT genus + species ;
			FROM species JOIN site ON species.pkey = site.fkey ;
			WHERE site.continent = 'Africa' );
UNION  ;
SELECT genus, species, continent ;
	FROM species JOIN site ON species.pkey = site.fkey ;
	WHERE site.continent = 'Africa' ;
		AND genus + species IN ( ;
			SELECT genus + species ;
			FROM species JOIN site ON species.pkey = site.fkey ;
			WHERE site.continent = 'Asia' );
	ORDER BY 1,2 ;
	INTO CURSOR curAA
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform