Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AS Clause
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00409807
Message ID:
00409887
Views:
37
>>>>Hi Jim,
>>>>
>>>>>>When i execute the folowing SQL query, i get the error colomn "WTG"not found.
>>>>>>
>>>>>>SELECT detail.avr_ari,;
>>>>>> iif(Detail.avr_wtg=.t.,'J','N') as WTG;
>>>>>>FROM general!detail;
>>>>>>WHERE WTG='J'
>>>>>>
>>>>>>Is this an impossible kind of query, to include an expressionalias in the WHERE Clause ?
>>>>>>
>>>>>>Any idea's how to solve this ?
>>>>>>
>>>>>
>>>>>Bjorn,
>>>>>
>>>>>The WHERE clause of SELECT si applied to the source tables, there is no fild named WTG in the source fields. You can change it to;
>>>>>
>>>>>WHERE Detail.avr_wtg = "J"
>>>>>
>>>>
>>>>This will cause a data-type mismatch. If he's testing against the result of the iif(), he's got to use the HAVING clause.
>>>
>>>Naw, you don't need a HAVING or a comparison operator, simply
SELECT detail.avr_ari, "J" AS WTG;
>>>FROM general!detail;
>>>WHERE Detail.avr_wtg
will do the trick. Using Detail.avr_wtg = .T. slows things down.
>>
>> George,
>>
>> If you have index on avg_wtg (though it would be strange to have index on logical field), I assume, where avr_wtg=.t. should be faster than where avr_wtg
>>
>>Correct me, please, if I'm wrong.
>
>No, it wouldn't be. This is because whenever you have a comparison operator, both sides of the expression must be evaluated.

Thanks for the explanantion. I revise the logic in one of my application to not include .f./.t. in where condition for logical fields
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform