Test: A B C ----- ---- ---- ABC B C DEF E FSELECT [A] ,[B] ,[C] FROM [Test].[dbo].[Test] WHERE [A] LIKE 'A'+[B]+[C] /* A B C ---------- ABC B C(1 個資料列受到影響) */
create table #tb ( u_photo_id int, [name] nvarchar(50), sex nvarchar(50), u_document_id int )--生产测试数据 insert into #tb select 1,'ad','d',1 union all select 4,'b','d',1 union all select 7,'r','d',2 union all select 6,'c','d' ,1 select * from #tb where #tb.[name] like 'a' + #tb.sexdrop table #tb 结果: 1 ad d 1
SELECT [A] ,[B] ,[C] FROM [Test].[dbo].[Test] WHERE [A] LIKE 'D'+[B]+[C] /* A B C ------------- DEF E F(1 個資料列受到影響) */
declare @t table(A1 varchar(10),A2 varchar(10)) insert @t select 'AB','B' insert @t select 'ADS','aeaeae' insert @t select 'EWS','Dssd' select * from @t where A1 like '%'+[A2]A1 A2 ---------- ---------- AB B(1 row(s) affected)
路过学习SELECT A.* FROM A WHERE A.A1 LIKE "?" + A.A2 写为 SELECT A.* FROM A WHERE A.A1 LIKE '_' + A.A2
A B C
----- ---- ----
ABC B C
DEF E FSELECT [A]
,[B]
,[C]
FROM [Test].[dbo].[Test]
WHERE [A] LIKE 'A'+[B]+[C]
/*
A B C
----------
ABC B C(1 個資料列受到影響)
*/
(
u_photo_id int,
[name] nvarchar(50),
sex nvarchar(50),
u_document_id int
)--生产测试数据
insert into #tb
select 1,'ad','d',1 union all
select 4,'b','d',1 union all
select 7,'r','d',2 union all
select 6,'c','d' ,1 select * from #tb where #tb.[name] like 'a' + #tb.sexdrop table #tb
结果:
1 ad d 1
SELECT [A]
,[B]
,[C]
FROM [Test].[dbo].[Test]
WHERE [A] LIKE 'D'+[B]+[C]
/*
A B C
-------------
DEF E F(1 個資料列受到影響)
*/
insert @t select 'AB','B'
insert @t select 'ADS','aeaeae'
insert @t select 'EWS','Dssd'
select * from @t where A1 like '%'+[A2]A1 A2
---------- ----------
AB B(1 row(s) affected)
写为
SELECT A.* FROM A WHERE A.A1 LIKE '_' + A.A2