For example you have a table user_info in which user_name is a field and you want to capatilize the first word of user_name and other words in lower case then
Then you can do this by using mysql inbuild funcitons
CONCAT() --> For concating the string
UCASE() -->Changing string into upper case
LCASE() --> Changing String into lower case
LEFT() --> You can defined the words(substring) you want starting from left
RIGHT() --> You can defined the words(substring) you want starting from right
LENGTH() --> You can find the length of string
Now the query
select CONCAT(UCASE(left(user_name,1)),LCASE(right(user_name,length(user_name)-1))) from user_info;
If previous output is
sAndeep
singh
BISHT
then the output became
Sandeep
Singh
Bisht
No comments:
Post a Comment