select a.* from a,c where ltrim(c.d) like '%'+ltrim(a.b)
select * from a,c where rtrim(a.b) like '%'+rtrim(ltrim(c.d))
---测试数据--- if object_id('[a]') is not null drop table [a] go create table [a]([b] int) insert [a] select 253 if object_id('[c]') is not null drop table [c] go create table [c]([d] int) insert [c] select 53
---查询--- select a.* from a,c where charindex(ltrim(c.d),ltrim(a.b))>0select a.* from a,c where ltrim(a.b) like '%'+ltrim(c.d)---结果--- b ----------- 253(所影响的行数为 1 行)
if object_id('[a]') is not null drop table [a]
go
create table [a]([b] int)
insert [a]
select 253
if object_id('[c]') is not null drop table [c]
go
create table [c]([d] int)
insert [c]
select 53
---查询---
select a.* from a,c where charindex(ltrim(c.d),ltrim(a.b))>0select a.* from a,c where ltrim(a.b) like '%'+ltrim(c.d)---结果---
b
-----------
253(所影响的行数为 1 行)