Stilyan Kolarov
Stilyan Kolarov

Reputation: 3

Replace first char in text column

I have codes in a text column, for example, e12312312 E123123123 need to write sql query who make every value in a column with capital E my database is postgresql

Upvotes: 0

Views: 567

Answers (1)

GMB
GMB

Reputation: 222482

You can use Postgres string function initcap() to turn the first character of a string to upper case and the rest of the string to lower case : since the rest of your strings is made of digits only, this should work:

select initcap('e12312312')

If your string may contain other upper case letters than you do not want to lower, then you can use left(), right() and upper():

select upper(left('e12312312ABC', 1)) || right('e12312312ABC', -1);

Upvotes: 1

Related Questions