sql中的reverse功能

 

要把用戶電話號碼中,倒數第三位是2,倒數第二位是6,最後一位是偶數的號碼列出來

declare @tab table(tel varchar(50))

insert @tab values('13455555555')
insert @tab values('13455555266')

insert @tab values('13455555557')
insert @tab values('13455555258')
insert @tab values('13455555269')


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

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

REVERSE

能把一個字符串倒過來

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章