Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Some Help with Select statement
Message
From
22/09/2003 08:58:52
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00830332
Message ID:
00831044
Views:
20
>>Caroline,
>>Probably you wouldn't want to use "IN (...)", due to its limitation, right ?
>>Assuming you first would want to get paper IDs into a cursor. ie:
>>
>>
>>Create Cursor crsPapers (ItemID i)
>>Insert into crsPapers values (1)
>>Insert into crsPapers values (2)
>>
>>* ItemId 1 is The Times
>>* ItemId 2 is The Sunday Times
>>Select CustID from Subs s ;
>>  left join crsPapers p on s.ItemID = p.ItemID ;
>>  having cnt(s.ItemID) = Reccount('crsPapers') and ;
>>	cnt(s.ItemID) = cnt(p.ItemID) ;
>>  group by custID
>>
>>With an IN (lcList) it might be :
>>
>>
>>* ItemId 1 is The Times
>>* ItemId 2 is The Sunday Times
>>lcList = '1,2'
>>Select CustID from Subs s ;
>> left join Papers p ;
>> on s.ItemID = p.ItemID and p.ItemId in (&lcList) ;
>> having cnt(s.ItemID) = Occurs(',',m.lcList)+1 and ;
>>	cnt(s.ItemID) = cnt(p.ItemID) ;
>> group by custID
Cetin
>
>Thanks Cetin that seems to work. I've just got to incorporate the new cursor into my code then I'm away.
>Many thanks
>Caroline

Glad:) If that would be a view I think you could make that cursor parametric. ie:
&& In command window
Create Cursor crsPapers (ItemID i)
Insert into crsPapers values (1)
Insert into crsPapers values (2)

m.crsPapers = 'crsPapers' 

create sql view as v_subs as ;
Select CustID from Subs s ;
  left join ?crsPapers p on s.ItemID = p.ItemID ;
  having cnt(s.ItemID) = Reccount(?crsPapers) and ;
	cnt(s.ItemID) = cnt(p.ItemID) ;
  group by custID

* Then once created
m.crsPapers = sys(2015)
select ItemID from Papers where ... into cursor (m.crsPapers) nofilter

use myDB!v_subs && or requery if in use
Would work I 'guess' :)
Cetin

Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform