SQL常用函数之四 REVERSE()

来源:互联网 发布:yaosir乒乓器材淘宝店 编辑:程序博客网 时间:2024/05/27 09:46

Reserve()函数是将指定的字符串顺序颠倒


要把用户电话号码中,倒数第三位是2,倒数第二位是6,最后一位是偶数的号码列出来
create table tab1 (tel varchar(50))
select * from tab1
insert into tab1 values('13455555555')
insert tab1 values('13455555266')

insert tab1 values('13455555557')
insert tab1 values('13455555258')
insert tab1 values('13455555269')

select * from tab1
select * from tab1 where substring(REVERSE(tel),3,1)=2
select * from tab1 where substring(REVERSE(tel),3,1)=2 and substring(REVERSE(tel),2,1)=6

select * from tab1 where substring(REVERSE(tel),3,1)=2 and substring(REVERSE(tel),2,1)=6
and substring(REVERSE(tel),1,1)%2=0

原创粉丝点击