LIKE keyword [message #8018] |
Tue, 22 July 2003 07:40 |
Just Me
Messages: 10 Registered: November 2000
|
Junior Member |
|
|
Hi,
I am using ORACLE 9i. I am trying to create a procedure using like keyword as follows:
UPPER(last_name)like '[[A-M]]%'
This does not seem to work. What is the correct way to use the like keyword or otherwise return last names starting with alphabets from A thru M?
Any help will be truly appreciated.
|
|
|
|
Re: LIKE keyword [message #8021 is a reply to message #8020] |
Tue, 22 July 2003 07:57 |
Just Me
Messages: 10 Registered: November 2000
|
Junior Member |
|
|
WOW!
Art, you are great!!
Can not thank you enough..once again!!! Believe it or not, I searched for this message before posting it today but did not find it.
Best Regards.
|
|
|
|
Re: LIKE keyword [message #8049 is a reply to message #8041] |
Wed, 23 July 2003 07:59 |
Art Metzer
Messages: 2480 Registered: December 2002
|
Senior Member |
|
|
Unfortunately, this approach (SELECT ename FROM emp WHERE UPPER(ename) BETWEEN 'A' AND 'M') will overlook all last names starting with 'M':SQL> SELECT e.ename
2 FROM emp e
3 WHERE UPPER(e.ename) BETWEEN 'A' AND 'M'
4 /
ENAME
----------
ALLEN
JONES
BLAKE
CLARK
KING
ADAMS
JAMES
FORD
8 rows selected.
SQL> SELECT e.ename
2 FROM emp e
3 WHERE ASCII(UPPER(e.ename)) BETWEEN ASCII('A')
4 AND ASCII('M')
5 /
ENAME
----------
ALLEN
JONES
<b>MARTIN</b>
BLAKE
CLARK
KING
ADAMS
JAMES
FORD
<b>MILLER</b>
10 rows selected.
SQL> The ASCII function, when presented with a parameter longer than one character, looks only at the first.
Art
|
|
|