Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql command 1

Status
Not open for further replies.

FoxKid

MIS
Jun 8, 2003
92
IN
I am having 3 fields in my dbf on which I have to do search as per option selected by user. i.e. shipmentdate, canceldate, orderdate
now, is there any way to write a single sql command to filter data or I have to write 3 different sql command and write that if user selects shipmentdate then do sql1 or if user selects canceldate then do sql2 or if user selects orderdate then do sql3

Please help me

santosh
 
Hi

if you have only one textbox collecting the date.. then

SELECT * FROM myTable ;
WHERE shipmentdate = myDate OR ;
canceldate = myDate OR ;
orderdate = myDate ;
INTO CURSOR .......

:)

ramani :)
(Subramanian.G)
 
Thanks Ramani,
But this is not I want. I am getting date in one text box and then asking user for the field he wants to search. If he selects orderdate then the sql should only search in orderdate field.

I think now you have understand

Thanks and Regards

santosh
 
Hi

You can build up the SQL text from variables.

CASE
<user selects shipmentdate>: sVar1=&quot;shipmentdate&quot;

<user selects canceldate>: sVar1=&quot;canceldate&quot;

<user selects orderdate>: sVar1=&quot;orderdate&quot;
ENDCASE

sSQLtext='SELECT * FROM myTable WHERE '+sVar1+'=myDate INTO CURSOR .....'

And now you can execute the SQL query.


MustangMan96

 
mustangman96
I have written the following codes

sVar1=&quot;shipmentda&quot;
sele * from buyerordersmaster where '+sVar1+'=ctod(&quot;01/07/03&quot;) into cursor temp

its giving operator/operand type mismatch

Please help

santosh
 
Thanks Ramani,
Its running well. I got exactly, what I want.
Thankyou once again

santosh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top