MySQL – Is There a Way to Trim Data Automatically?

MySQL

Lets I have a table named myTable in mysql with Three field

1. id int autoincrement
2. product_id varchar(20) not null
3. product_name varchar(200) not null

Now I want to keep data in product_id and product_name without white-space.

Best Answer

Yes, one way to do this will be to create a insert trigger on the table...can trim the values before inserting into the table ..