题解 | #获取Employees中的first_name#

获取Employees中的first_name

http://www.nowcoder.com/practice/74d90728827e44e2864cce8b26882105

本题可用两种函数解答 substr()与right()函数

1.substr(str,start,length)

注意:

1.字符串的第一个字符的索引是1。
2.值为正时从字符串开始位置开始计数,值为负时从字符串结尾位置开始计数。
3.长度不填时默认取到结尾。

// 方法一: 
select first_name from employees 
order by substr(first_name,-2);
// 方法二:  
select first_name from employees 
order by substr(first_name,length(first_name)-1,2); 

2.right(str,num) 函数。

从右边开始截取str字符串num长度.同理还有left函数

// 方法三:
select first_name from employees oeder by right(first_name,2);
全部评论

相关推荐

06-20 21:22
已编辑
门头沟学院 Java
纯真的河老师在喝茶:答应了就跑啊,实习随便跑啊,别被pua了,md就是找个廉价劳动力,还平稳过度正式工,到时候跟你说没转正
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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