General information
Category:
Coding, syntax & commands
>I'm doing select on a table with an ID that has 123,123A,123B. When I select * from table where alltrim(ID) = '123' I also get the records for 123A and 123B. Set exact doesn't effect it, what am I missing?
>
>TIA,
>
>E.R. Gilmore
This is an example of FoxPro's somewhat 'faulty' logic of comparing strings. FoxPro checks each character on the right side of the expression to each character of the left until it reaches the end of the string expression on the right. (eg if 'ABCDEF'='ABC' it compares the 'A','B','C' and then hits the end of the string) Fox then asks itself if it found any that didn't match. Since it didn't, Fox says that the strings must be equivillant. That's why you NEVER use an expression using '' (eg if 'ABCD'='') This will ALWAYS be true no matter what variable you use.
If you're looking for a quick fix, simply use the double equals (==). This forces Fox to check not only for content, but for length of the string as well.
P.S. make sure you are indexed on alltrim(ID) or Rushmore isn't used.
Good luck.
Tom
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only