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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT statement - return everything before Mits

Status
Not open for further replies.

jasonhuibers

Programmer
Sep 12, 2005
290
CA
I have a record value of:

TekMits

I want the result to be everything before Mits. So the record returned would be Tek.. How can I do this in a SELECT statement?

 


Select substr(Table.field,1,3)
from Table

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Sorry only thing is I never know what charcters are before the Mits...

 
There may be a more elegant solution but try this:
Code:
SELECT substr(fieldname,1,length(fieldname)-instr(fieldname,'Mits'))
  FROM tablename
 
Ahm, sorry, the above doesn't fit your requirement. This should do:
Code:
SELECT substr(fieldname,1,instr(fieldname,'Mits')-1)
  FROM tablename
 
Does every row contain the string, "Mits"? If not, the above code will print out nothing for the rows that do not contain "Mits". Is that what you want?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top