Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL : Select multiple filter condition using variable ?
Message
From
10/08/1999 21:53:15
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
To
10/08/1999 01:11:08
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00251869
Message ID:
00252328
Views:
8
Gan,

Having the user type all of that will surely cause problems. No user should be expected to format data so carefully.

Use checkboxes labeled Jan, Feb, etc.

Then do

cMySelectStatement = ;
[SELECT Whatever FROM Wherever ] + ;
[WHERE MyMonth IN (]

cMyWhereStatement = ;
IIF(JanIsChecked, [,"01/1999" ], []) + ;
IIF(FebIsChecked, [,"02/1999" ], []) + ; && etc.

cMySQL = cMySelectStatement + SUBSTR(cMyWhereStatement, 2)
&cMySQL

Note the removal of the extra comma on the front of the list of months.
This saves worrying about whether there is one field or several.

Again, remember the advice you have been given: use a 4-digit year!

>All,
>
>I have a SQL SELECT statement for retrieving my data, and one of the major item is the filter condition, as follow:
>
>SELECT ................ WHERE mycursor.month IN ("02/99","04/99")
>
>However, I need to allow the user the enter the filter condition that he wants in a textbox with the controlsource of the textbox is set to a memory variable (eg, mMonth).
>
>Example,
>The user will type :
>"02/99","04/99","06"/99"
>
>to filter the month of Feb99,Apr99 and Jun99 which are separated by commas.
>
>Therefore, I put the statement as WHERE mycursor.month IN (mMonth), but the command treated mMonth as a string.
>How should I deal with things like this? Suggestion?
>
>Thanks,
>Gan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform