Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String comparisons in SQL SELECT
Message
From
29/05/2002 05:33:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/05/2002 23:31:23
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00661853
Message ID:
00662334
Views:
21
>Thanks a lot, this clears up a number of things for me.
>
>Just one more question on this:
>
>can I get the equivalent of using == with a BETWEEN statement? as I get the same problem when using BETWEEN, preferably without SET ANSI ON as it may affect older code.
>
>TIA, Craig.

With or w/o ansi no. Strings are included in a alphabetic sort order and it would mean '2' would come after '103' and before '210' :
myField between '103' and '210'
would get that '2' too. If that's what you really want then OK. I see that you use '103' in your sampling and thus I suspect all are somewhat numeric values. If so then you might be much more comfortable using val() instead :

where val(myField) = 103
where val(myField) between 103 and 210

If field contains some char too (ie: 103, 103R, 19B) you might then make it still numeric sort ordered with functions like padl(), chrtran().
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform