某一个字段是varchar类型。里面存储的是URL:http://yao.xywy.com/goods/ 90000.htm
我想按红色的数字部分,进行排序。
谢谢
4 个解决方案
#1
千万别删我帖子啊,上次不知道谁给我删了。我过了两天打开一看,是404。汗
#2
declare @s varchar(100)
set @s='http://yao.xywy.com/goods/90000.htm'
select substring(substring(@s, len(@s) - patindex('%/%', REVERSE(@s)) + 2, 100), 1, len(substring(@s, len(@s) - patindex('%/%', REVERSE(@s)) + 2, 100))-4)
得出结果就可以排序了。
#3
declare @s varchar(100)
set @s='http://yao.xywy.com/goods/90000.htm'
select left(right(@s,CHARINDEX('/',REVERSE(@s))-1),CHARINDEX('.',right(@s,CHARINDEX('/',REVERSE(@s))-1))-1)
#4
SELECT * FROM TB
ORDER BY CAST(SUBSTRING(URL,27,LEN(URL)-30) AS INT)
#1
千万别删我帖子啊,上次不知道谁给我删了。我过了两天打开一看,是404。汗
#2
declare @s varchar(100)
set @s='http://yao.xywy.com/goods/90000.htm'
select substring(substring(@s, len(@s) - patindex('%/%', REVERSE(@s)) + 2, 100), 1, len(substring(@s, len(@s) - patindex('%/%', REVERSE(@s)) + 2, 100))-4)
得出结果就可以排序了。
#3
declare @s varchar(100)
set @s='http://yao.xywy.com/goods/90000.htm'
select left(right(@s,CHARINDEX('/',REVERSE(@s))-1),CHARINDEX('.',right(@s,CHARINDEX('/',REVERSE(@s))-1))-1)
#4
SELECT * FROM TB
ORDER BY CAST(SUBSTRING(URL,27,LEN(URL)-30) AS INT)