A
A
Alexey2016-11-24 17:55:22
MySQL
Alexey, 2016-11-24 17:55:22

How to remove spaces in a column at the beginning of each value?

I have a database with a product table and a producte_code column . Is it possible to make an SQL query to remove spaces at the beginning of each value in the product_code column ?
Some products in the online store, when filling out, content managers wrote down with a space at the beginning of the product name. I would like to fix everything with one request.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-11-24
@a1exDi

update product t 
set t.product_code = trim(t.product_code) 
where t.product_code != trim(t.product_code);

It is possible without the where clause. You need to watch if something breaks (for example, some consumers look at the date of the last row update).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question