I have the following query in which I would like the field PUESTO
to return its Capitalized value, I want to say the first letter of each word in uppercase and the rest in lowercase
I have the query as follows:
select
DEPTO,
SUBSTRING(UPPER(PUESTO),1,1) + SUBSTRING(LOWER(PUESTO),2,50),
from Personal
This query returns the value but with the first letter of the entire string capitalized, I would like it to be the first letter of each word.
That type of case is called, in English, Proper Case or Title Case .
You can write a function to perform the task, for example, in this StackOverflow answer in English, I found this function that does the dirty work:
Once the function is created, use it in your select statement like so:
One suggestion I'd like to give you is that instead of calling this function every time, you update the information found in the table, for example:
Of course, then, you have to do this every time you enter/update a new record, but it will make your database more efficient, since the number of times a record is done
select
is usually greater than the number of times it is inserted/updated. these types of records.