Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select with CASE statement
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01665779
Message ID:
01665781
Views:
49
It is a SQL Server
The actual statement would be like this
select * from mytable where case when mytable.order_no > 0 then mytable.field2 = 1 else 1=1 end 
That is, I want the WHERE only fire when the order_no > 0. Otherwise, do not apply WHERE; hence the 1=1


>Your query doesn't make any sense. Care to explain what you are trying to accomplish? And is it VFP or SQL Server?
>
>>
>>I am going crazy as to why the following give an error:
>>
>>
>>select * from mytable where case when mytable.order_no > 0 then 1=1 else 1=0 end 
>>
>>
>>What is missing in the above?
>>
>>TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform