Reputation: 3
I have 'zipcode' column with value 19707-1234. I have to remove hyphen in between and change the value to 197071234. Can anyone please help me, how to do this using sql query irrespective of index?
Upvotes: 0
Views: 868
Reputation: 31993
In mysql I have used below query for replacing hyphen
*SELECT concat( SUBSTRING_INDEX('0125-3256','-',1),SUBSTRING_INDEX('0125-3256','-',-1)) as replace_hypen*
Output of this query = '01253256'
So you can use for zipcode code column
SELECT concat( SUBSTRING_INDEX(zipcode,'-',1),SUBSTRING_INDEX(zipcode,'-',-1)) as replace_hypen
Upvotes: 0
Reputation: 366
We a have built in replace function,you can use that
Declare @zipcode varchar(50)='19707-1234'
Select replace(@zipcode,'-','')
Upvotes: 0
Reputation: 6050
Use inbuilt REPLACE function of SQL.
SELECT REPLACE('19707-1234','-','');
Upvotes: 0
Reputation: 5656
You can simply use the replace function:
SELECT REPLACE(zipcode, '-', '')
Upvotes: 1