Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Some help with a sub-query
Message
 
To
27/03/2002 06:21:47
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00637702
Message ID:
00637721
Views:
20
>>Hi all,
>>
>>I'm new to sub-queries and I was wondering if it was possible to combine the following into one select statement using a sub-query.
>>
>>
>>Select * ;
>>FROM Links;
>>WHERE Links.itype in (1,0);
>>GROUP BY links.iwork;
>>INTO CURSOR Linked
>>
>>SELECT Exhibit.iid, Exhibit.nkey, linked.*;
>>FROM Exhibit LEFT OUTER JOIN Linked ON Exhibit.iid =Linked.iwork
>>
>>
>>Any help would be greatly appreciated.
>
>Caroline,
>
>Does this approach what you're after ?
>
>
>select	Exhibit.iid, ;
>	Exhibit.nkey, ;
>	L1.* ;
>    from Exhibit, Links L1 ;
>    where    ( Exhibit.iid ;
>		in	( select Distinct L2.iwork ;
>				from Links L2 ;
> 			   where    ( L2.itype in (0,1) ) ;
>			) ;
>		) ;
>	   and	( Exhibit.iid == L1.iWork )
>
Gregory

I don't think so. If I explain it in words:
The Exhibit table has records with Key numbers and the Links table has multiple records with an Exhibit key and a type. What I want in my result is 1 entry for every Exhibit key and a matching link of a particular type though that type could be 1 of 2 possible types or may not even be there.

So my original code initially collected all links of the 2 types, grouped these so that I have only one for each key in the link table.

The second part then does an outer join with the above result so that I have a record for every exhibit key with a link type if one matched the above options.

Is this possible?
Caroline
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform