题解 | #顾客登录名#

顾客登录名

https://www.nowcoder.com/practice/7cbf5e3082954c21a80fc750ce97350f

select cust_id,cust_name,upper(concat(left(cust_contact,2),left(cust_city,3))) user_login from Customers;

1、从左开始截取字符串

SELECT LEFT(str,len)

str:被截取的字符串

len:截取长度

2、从右开始截取字符串

SELECT RIGHT(str,len)

str:被截取的字符串

len:截取长度

第二种方法:

select cust_id,cust_name,

upper(concat(substring(cust_name,1,2),substring(cust_city,1,3))) as user_login

from Customers

  • 字符串的截取:substring(字符串,起始位置,截取字符数)
  • 字符串的拼接:concat(字符串1,字符串2,字符串3,...)
  • 字母大写:upper(字符串)
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务