I started with the LIKE operator but must be doing something wrong since I get no hits using it without padding it with underscores.
the app i'm developing (a conversion from MS access) is a boat registration data base where the vessel reg numbers might appear as "HA 1234 CF", or "HA 6500 E ". char(10) with a space in the data.
LIKE only works for me when I pad with the underscore.
Select * from myfile where myfield LIKE "________CF" = works to return all records that end with "CF".
Select * from myfile where myfield LIKE "CF" = does not work and finds zero records.
Select * from myfile where "CF" $ myfield = works to return all records that end with "CF".
I want to allow wildcard searches but have not decided the best way to approach this as yet. My plan is to allow the user to enter '?' or '*' parse the entry, and build the Select. Right now the $ Operator seems the easier of the two. I understand it's not Rushmore optimized, but I only have 50,000 records - so it seems quick enough.
Select * from myfile where myfield LIKE "CF" = does not work and finds zero records.
Change the above statement to :
Select * from myfile where myfield LIKE "%CF"
- will fetch the records. You need to use % to suggest any character(s) before "CF". If "CF" was somewhere in the middle of the string you could use "%CF%". You can also use a combination of "_" and "%" depending on your search requirements.
However it is not an undocumented feature. Both "%" and "_" are documented SQL select wildcard characters and mentioned in the online help on SELECT - SQL command. "%" represents a sequence of unknown characters and "_" represents a single unknown character in a string.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.