Can we do the opposite of the INITCAP() function? It sets the first letter of each word to lowercase and rest of the letters to upper case.
For example, SOMEFUNCTION(abc) returns aBC.
Below you can find a function for MySQL.
delimiter //
create function lower_first (input varchar(255))
returns varchar(255)
deterministic
begin
declare len int;
declare i int;
set len = char_length(input);
set input = upper(input);
set i = 0;
while (i < len) do
if (mid(input,i,1) = ' ' or i = 0) then
if (i < len) then
set input = concat(
left(input,i),
lower(mid(input,i + 1,1)),
right(input,len - i - 1)
);
end if;
end if;
set i = i + 1;
end while;
return input;
end; //
delimiter ;
select lower_first('this is my TeSt'); -- tHIS iS mY tEST
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