John Kim
John Kim

Reputation: 1882

Remove percentage sign from values in MySQL table

I have a lot of rows with values with percentage sign that I would like to remove from a column.

Is there a good SQL query to achieve this?

Upvotes: 2

Views: 5253

Answers (3)

kelley805
kelley805

Reputation: 1

If your DBMS does NOT have a "replace" function, you will have to use character substitution using several string functions.

Here is an example in Sybase and SQL Server.

UPDATE YourTable
SET YourColumn = stuff(YourColumn, patindex(YourColumn, '%'), 1, NULL)

This code will find the pattern of '%' in YourColumn, then use that position number to replace the character with NULL.

Upvotes: 0

juergen d
juergen d

Reputation: 204924

update your_table set your_column = replace(your_column, '%', '')

Upvotes: 1

Joe Stefanelli
Joe Stefanelli

Reputation: 135938

Use the REPLACE function:

UPDATE YourTable
    SET YourColumn = REPLACE(YourColumn, '%', '');

Upvotes: 8

Related Questions