Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LIKE ('4*-8002') works, LIKE('4??-8002') doesn't
Message
From
04/11/1999 20:51:32
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00287283
Message ID:
00287290
Views:
13
Ed,

Fund codes are of the form '123-5678' with no spaces. Again, how does '4??-8002' work in the watch window and command window, but not as a function in the SQL? I can see if LIKE() didn't work at all in SQL, but for the *'s to work and not the ?'s mystifies me.




>This is a guess, but it has to do with how the wildcards * and ? work. An * matches any sequence of zero or more characters, while the ? matches exactly any one character. Therefore, if your value is stored in the fund as:
>
>"499 -8002"
>
>4*-8002 matches, with * representing "99 ", while 4??-8002 fails, since the two ? characters match the two 9s, but ' -8002' is not the same as "-8002"
>
>Similarly with "49-8002" as a data value, the * works, but ?? doesn't, since '8002' is not the same as "-8002"...
>
>Isn't pattern matching fun?????



>>Anybody know any gotcha's with LIKE? Our fund codes are in the form: '123-4567'. I am using SELECT against Fox tables.
>>
>>This evaluates .T. against records in the table in the watch window as expected:
>>LIKE('4??-8002', ALLT(PyrlDist.Fund))
>>
>>but does not work within a SELECT:
>>SELECT SUM(IIF(LIKE('4??-8002', ALLT(PyrlDist.Fund)), 1, 0)) AS ...
>>
>>But this SELECTs data correctly:
>>SELECT SUM(IIF(LIKE('4*-8002', ALLT(PyrlDist.Fund)), 1, 0)) AS ...
>>
>>So I can get my data, but I'd like to know why the ??'s didn't work. Any ideas?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform