Home » SQL & PL/SQL » SQL & PL/SQL » LIKE keyword
LIKE keyword [message #8018] Tue, 22 July 2003 07:40 Go to next message
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 #8020 is a reply to message #8018] Tue, 22 July 2003 07:51 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
http://www.orafaq.net/msgboard/newbies/messages/8879.htm

A.
Re: LIKE keyword [message #8021 is a reply to message #8020] Tue, 22 July 2003 07:57 Go to previous messageGo to next message
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 #8041 is a reply to message #8018] Tue, 22 July 2003 23:18 Go to previous messageGo to next message
Prodigy
Messages: 2
Registered: July 2003
Junior Member
This should help u

select ename from emp where upper(ename) between('A') and ('M')

Regds,
Prodigy
Re: LIKE keyword [message #8049 is a reply to message #8041] Wed, 23 July 2003 07:59 Go to previous message
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
Previous Topic: Karri
Next Topic: current_date + interval 'x' question
Goto Forum:
  


Current Time: Wed Apr 24 07:02:33 CDT 2024