Hello
I would like to select all records that have an underscore character in their 11th character, so i try this:
SELECT * FROM "BOM_SUB_LEVEL" where TOP_CODE like '%%%%%%%%%%_%%%'
but this doesnt work as expected, can someone help?
thanks
Hello
I would like to select all records that have an underscore character in their 11th character, so i try this:
SELECT * FROM "BOM_SUB_LEVEL" where TOP_CODE like '%%%%%%%%%%_%%%'
but this doesnt work as expected, can someone help?
thanks
For a single character wildcard use _
. For multiple characters wildcards, use %
. To escape a "real" appearance of _
, use \_
(thanks Bill!).
Try the following code:
SELECT * FROM "BOM_SUB_LEVEL" where TOP_CODE like '___________\_%'
To further elaborate following Dav's comment, note that '%%%' is exactly the same as '%', since by definition '%' covers multiple characters.
Just use the "SUBSTRING" function :
SELECT * FROM "BOM_SUB_LEVEL" where SUBSTRING(TOP_CODE, 11, 1) = "_"
Marc
The % is not a per character wildcard, its a beginning and end of string wild card.
i.e. if I want to find all rows that have "car" in them, I would do this:
Select * from myTable where myCol LIKE '%car%'
If I wanted just the rows that STARTED with car:
Select * from myTable where myCol LIKE 'car%'
and ended with car:
Select * from myTable where myCol LIKE '%car'
% is a wildcard and can replace an character, or combination of characters. Use ? instead which replaces a single character.
LIKE % can mean any number of characters, use LIKE _ to mean just one. Since you're looking for an underscore, you need to escape it with !.
SELECT * FROM BOM_SUB_LEVEL WHERE TOP_CODE LIKE '__________!_%'
You can try something like: (play with the numbers, I don't have pervasive to test with)
SELECT *
FROM BOM_SUB_LEVEL
where SUBSTRING(TOP_CODE, 11,1) = '-'
pervasive uses _ to match any single character and \_ to actually match an underscore.
so the select would be:
SELECT * FROM "BOM_SUB_LEVEL" where TOP_CODE like '___________\_%'