Packy Packy - 1 year ago 80
SQL Question

Remove commas from databse column

Basically in a table I want to remove all commas in

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


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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download