Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Syntax

Status
Not open for further replies.

DirtyB

Programmer
Mar 13, 2001
159
US
I am new at PL/SQL and have some basic syntactical questions. Can anyone point me to a good web reference?

I apologize if this is not the correct forum for this, I can't seem to find another one more fitting?

One question I had is, how do I select the leftmost N characters of a field? For example, I need to find every name in the LastName field, where the left 3 characters are the same?

Thanks
 
Select personid from mypeople where substr(lastname, 1, 3) = p_begining;

where p_begining is the 3 letters you pass to the PL/SQL

Or are you wanting to find ALL people who match in first three?

select a.personid from mypeople a, mypeople b where substr(a.lastname, 1, 3) = substr(b.lastname, 1, 3) and a.personid <> b.personid; I tried to remain child-like, all I acheived was childish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top