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.
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.
What database?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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))
Oracle - substr(name,instr(name,"="
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>
@Alex,
Replace has already been suggested. Did we miss something?
Replace has already been suggested. Did we miss something?
need help with a SQL selectIt was just for the sake of completeness as he asked for a "SELECT" ;-)