Related String Functions in SQL

1667. Fix names in tables

https://leetcode.cn/problems/fix-names-in-a-table/

CONCAT() function, CONCAT can splice multiple strings together.

1. LEFT(str, length) function

Intercept the string from the left, length is the length of the interception.

2. UPPER(str) 与 LOWER(str)

UPPER(str) Convert all characters in the string to uppercase

LOWER(str) Convert all characters in the string to lowercase

3. SUBSTRING(str, begin, end)

Intercept the string, end is empty by default.

SUBSTRING(name, 2) Intercept from the second to the end, note that it is not the subscript, but the second.

# CONCAT is used to concatenate strings

● LEFT Extract characters from the left

● RIGHT Extract characters from the right

● UPPER becomes uppercase

● LOWER becomes lowercase

● LENGTH Gets the string length

select user_id,
concat(upper(left(name,1)),lower(substr(name,2)))
as name 
from Users
order by user_id;

Guess you like

Origin blog.csdn.net/weixin_56194193/article/details/129118127