以下数据条数据
name为nvarchar(40)
id name
1 111
2 ?
3 ??????????????????
4 ???????????????
使用SQL查询,语句如下:
select * from table where name like '%1%' 有数据
select * from table where name like '%?%' 无数据
select * from table where name like N'%?%' 有数据
select * from table where name like '%????%' 无数据
select * from table where name like N'%????%' 后面两条数据(第四条数据,肉眼看,怎么LIKE出来的?)
请教高手
------解决方案--------------------
if OBJECT_ID('tempdb..#temp', 'u') is not null drop table #temp;
go
create table #temp( [id] int, [name] nvarchar(40));
insert #temp
select '1',N'111' union all
select '2',N'?' union all
select '3',N'??????????????????' union all
select '4',N'???????????????'
--SQL:
--select * from #temp
--select * from #temp where name like '%1%' --有数据
--select * from #temp where name like '%?%' --无数据
--select * from #temp where name like N'%?%' --有数据
--select * from #temp where name like '%????%' --无数据
select * from #temp where name like N'%????%' --后面两条数据(第四条数据,肉眼看,怎么LIKE出来的?)
--?和?如果不区别大小写,就查出来了3包含:"????", 4包含:"????"