Link to home
Start Free TrialLog in
Avatar of tmajor99
tmajor99

asked on

SQL Select - Remove Value

I need help with a SQL select that will remove a static value from a column value.  

ID           Name
123        http://attribute?id=eco_123
233        http://attribute?id=eco_444

Expected results
ID           Name
123        eco_123
233        eco_444

I just want to remove "http://attribute?id=" value from NAME column.
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

What database?
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If it is ALWAYS that string, replace it?

Oracle:
replace(name,'http://attribute?id=')
should have refreshed before posting the followup...  :(
You can also use a substring function in either Oracle or SQL Server
Oracle - substr(name,instr(name,"=") + 1)
SQL Server - substring(name, charindex("=",name) + 1,len(name))
@awking: this would also remove elements in strings like '1=1'. So it may remove too much.
select ID, replace(Name, 'http://attribute?id=', '') Name from <your_table>

Open in new window

@Alex,

Replace has already been suggested.  Did we miss something?
need help with a SQL select
It was just for the sake of completeness as he asked for a "SELECT" ;-)