Posted: Thu Aug 10, 2006 8:29 am Post subject: STRING edits
Hi friends,
I have a following task in hand.
Mine is a DB2 database. I have a field which is CHARACTER (10).
I need to find out the rows which has :
an ALPHABET anywhere in this field. ex : 123ABC12, 1A11111...etc.
3 or more consecutive numbers. Ex (123ABC, ABC111111,A123B23456...etc)
Joined: 26 Nov 2002 Posts: 12401 Topics: 75 Location: San Jose
Posted: Thu Aug 10, 2006 6:39 pm Post subject:
spalanis,
The following Sql will give you the desired results (untested sql's)
1.
Code:
SELECT *
FROM TABLE
WHERE STRIP(TRANSLATE(tbl_col,'$','1234567890','$'),B,'$') > ' '
;
2.
Code:
SELECT *
FROM TABLE
WHERE SUBSTR(STRIP(TRANSLATE(tbl_col,'$',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ','$'),B,'$'),1,1) NOT IN ('$',' ')
AND SUBSTR(STRIP(TRANSLATE(tbl_col,'$',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ','$'),B,'$'),2,1) NOT IN ('$',' ')
AND SUBSTR(STRIP(TRANSLATE(tbl_col,'$',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ','$'),B,'$'),3,1) NOT IN ('$',' ')
;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum