create table tb(col varchar(10)) insert into tb select 'abcdefg' union all select 'ghijklm' go select left(REVERSE(col),1) from tb /* ---- g m(2 行受影响)*/ go drop table tb
select * from table where SUBSTRING([列名],LEN([列名])-1,2)='条件' 求鉴定
select substring(reverse('acb'),1,1)
declare @table table (colname varchar(14)) insert into @table select 'aaaa条件' union all select 'bbbb' union all select 'cccc条件' union all select 'dddd'select * from @table where substring(colname,len(colname)-1,2)='条件' /* colname -------------- aaaa条件 cccc条件 */ select * from @table where right(colname,2)='条件' /* colname -------------- aaaa条件 cccc条件 */
insert into tb select 'abcdefg' union all select 'ghijklm'
go
select left(REVERSE(col),1) from tb
/*
----
g
m(2 行受影响)*/
go
drop table tb
求鉴定
select substring(reverse('acb'),1,1)
declare @table table (colname varchar(14))
insert into @table
select 'aaaa条件' union all
select 'bbbb' union all
select 'cccc条件' union all
select 'dddd'select * from @table where substring(colname,len(colname)-1,2)='条件'
/*
colname
--------------
aaaa条件
cccc条件
*/
select * from @table where right(colname,2)='条件'
/*
colname
--------------
aaaa条件
cccc条件
*/