Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL BETWEEN Question
Message
From
17/01/2002 11:31:36
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
SQL BETWEEN Question
Miscellaneous
Thread ID:
00606143
Message ID:
00606143
Views:
53
I have a range of values in a table that use character data. The value that I am querying is also a character data type (C). When I run the below query I get two rows returned when using BETWEEN with a character data type but only one when using a numeric data type. Seems odd that I can not use character values for this query:
SET ANSI ON

SELECT * FROM tbl WHERE '102108' BETWEEN pin_beg AND pin_end

Pkx  Pin_beg	 Pin_end  
 2   10000  	 11999    
17   100000 	 199999 


SELECT * from tbl WHERE VAL('102108') between VAL(pin_beg) AND VAL(pin_end)

Pkx  Pin_beg	 Pin_end  
17   100000 	 199999 
The 2nd SQL statement works correctly but I am not sure why the first one returned two rows. Anyone know why?
Next
Reply
Map
View

Click here to load this message in the networking platform