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

substring question

Status
Not open for further replies.

ITbeast

IS-IT--Management
Jul 25, 2006
67
US
I have a query that works fine for my initial database population, but I need another one for after that point. Basically, I have a field that comes out as DOMAIN1+username but all I want is the user name. So I came up with this mysql statement that works OK:

update logfile set rfc931 = substring(rfc931,9,64) where rfc931 is not null;

But now I want to only modify fields that only have the DOMAIN+username value, not the already stripped down field of just username. I've tried several if then statements but none seem to come out properly. My last try was:

if substring(rfc931,8,1) = '+' then update logfile set rfc931 = substring(rfc931,9,64) where rfc931 is not null;


This gives errors also. I can't find a good resource on the internet to give me examples of syntax. Any help would be appericated!
 
What about:
Code:
update logfile
set rfc931 = substring(rfc931,9,64) 
where rfc931 is not null
   and substring(rfc931,8,1) = '+'

[red]not tested so no warranties on your data after you try that[/red]
 
That did the trick, thanks for the help. Sorry if it was a really easy question but I'm not a SQL guy I'm just trying to get this one application working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top