Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with CASE statement
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01665779
Message ID:
01665781
Vues:
50
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform