I have multiple web services that write data inside a database table. I'd like to automatic convert uppercase strings into lowercase ones, for a specific field. Is there any mysql function that performs this task?
Suppose this is the table:
id | name | language
Sometimes, inside the language field, web services write an uppercase string (IT). I want to convert it into a lowercase string ("it"), directly inside MySQL.
thanks
Define triggers on the table:
CREATE TRIGGER lcase_insert BEFORE INSERT ON my_table FOR EACH ROW
SET NEW.language = LOWER(NEW.language);
CREATE TRIGGER lcase_update BEFORE UPDATE ON my_table FOR EACH ROW
SET NEW.language = LOWER(NEW.language);
Then update the existing data:
UPDATE my_table SET language = LOWER(language);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With