• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

I need a little SQL help

Overload

Smash Lord
Joined
Jul 7, 2008
Messages
1,531
Location
RI
I need to turn something like "Doe/John M" into "John M Doe"
In other words, I have to switch the first and last names around and omit the slash.

I've having some trouble with it. I know I have to use SUBSTR and INSTR in conjunction, but can't get it to work the way I want it.
So far I have:
Code:
select substr(name,instr(name,'/'),9)||substr(name, 1, instr(name,'/'))
from members
where idno = '00001'
which returns
Code:
/John M Doe/
I don't want either of those slashes.
Is there another way to get all the characters before the slash without using a number (in this case 9)? The asterisk wildcard didn't work...

I feel like this should be simple, but am stumped none-the-less. Can anyone help me out?

EDIT: nvm, it's working:

Code:
select substr(name,instr(name,'/')+1)||substr(name, 1, instr(name,'/')-1)
from members
where idno = '00001'
 
Top Bottom