Home » SQL & PL/SQL » SQL & PL/SQL » SUBSTR and LPAD (oracle, 11.0, unix)
SUBSTR and LPAD [message #490205] Fri, 21 January 2011 16:22 Go to next message
goody
Messages: 14
Registered: January 2011
Location: Maryland
Junior Member
Hello,

I have a table with last names of different lengths. I want to substr off the last 3 characters of the last name. Is there a way of doing it without me having to left pad the last name field then, creating another temp table, then substr off the last 3 characters.

Any help would be greatly appreciated.
Re: SUBSTR and LPAD [message #490208 is a reply to message #490205] Fri, 21 January 2011 16:40 Go to previous messageGo to next message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
goody wrote on Fri, 21 January 2011 23:22
I want to substr off the last 3 characters of the last name. Is there a way of doing it without me having to left pad the last name field then, creating another temp table, then substr off the last 3 characters.

Yes, simply use SUBSTR function with negative (-3) position parameter.

Oracle SQL language is documented in SQL Reference book, which is available e.g. online on http://tahiti.oracle.com/ Please, consult it.
Re: SUBSTR and LPAD [message #490209 is a reply to message #490208] Fri, 21 January 2011 16:53 Go to previous messageGo to next message
goody
Messages: 14
Registered: January 2011
Location: Maryland
Junior Member
Thank you, it worked.
Re: SUBSTR and LPAD [message #490220 is a reply to message #490205] Sat, 22 January 2011 00:25 Go to previous message
Michel Cadot
Messages: 68763
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
As I said in your previous topic:
http://www.orafaq.com/forum/mv/msg/164897/489379/102589/#msg_489379

Quote:
Note that your example does not match with your definition:

Quote:
the first 2 character of the first name and the last 3 characters of the last name


Wink

Regards
Michel
Previous Topic: Need example of procedure to update a table
Next Topic: REF
Goto Forum:
  


Current Time: Wed Jul 23 18:35:17 CDT 2025