Packy Packy - 1 month ago 5
SQL Question

Remove commas from databse column

Basically in a table I want to remove all commas in

metadata_value
column entries someone put in where meta_key column is equal to 15, 16, or 17

So:

SELECT REPLACE(metadata_value, ',', '')
FROM project_content_to_metadata
WHERE metadata_key = '15'
AND metadata_key = '16'
AND metadata_key = '17'


But it did not work

Answer

If you actually want to remove the commas in the table, then use update:

update project_content_to_metadata
    set metadata_value =  REPLACE(metadata_value, ',', '')
    where metadata_key in (15, 16, 17);

Otherwise Kamil's answer is correct.

Comments