sql的用法。在table a里面进行模糊查询。我把查询语句写成var em;if(q){q='%
sql的用法。在tablea里面进行模糊查询。我把查询语句写成varem;if(q){q='%'+q+'%';em=alasql('SELECT*fromaWHEREa....
sql的用法。在table a里面进行模糊查询。我把查询语句写成var em;if(q){q='%'+q+'%'; em=alasql('SELECT * from a WHERE a.sch LIKE ?',[q]);} 其中a.sch的值是'C o U'(中间有空格),如果搜索时输入'C o U',即q='C o U(有空格)'或者'c'或'u'或'o'就能搜索得出。如果中间没有空格,即'CoU'或者'Co'或者'oU'都搜索不出来。这是什么原因呢?有什么办法能让不管有没有空格,都能搜索出来呢?
展开
展开全部
create table a
(<a href="https://www.baidu.com/s?wd=id&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">id</a> int,name varchar(20))
go
create table b
( b<a href="https://www.baidu.com/s?wd=id&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">id</a> int,nr varchar(20))
go
insert into a select 1,'哈哈' Union all
select 2,'呵呵' Union all
select 3,'喵'
insert into b select 2,'q' Union all
select 2,'w' Union all
select 2,'e' Union all
select 1,'r' Union all
select 1,'u'
select <a href="https://www.baidu.com/s?wd=id&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">id</a>,name,isnull((select COUNT(1) <a href="https://www.baidu.com/s?wd=from&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">from</a> b where bid=a.id),0) <a href="https://www.baidu.com/s?wd=from&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">from</a> a order by 3 desc
(<a href="https://www.baidu.com/s?wd=id&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">id</a> int,name varchar(20))
go
create table b
( b<a href="https://www.baidu.com/s?wd=id&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">id</a> int,nr varchar(20))
go
insert into a select 1,'哈哈' Union all
select 2,'呵呵' Union all
select 3,'喵'
insert into b select 2,'q' Union all
select 2,'w' Union all
select 2,'e' Union all
select 1,'r' Union all
select 1,'u'
select <a href="https://www.baidu.com/s?wd=id&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">id</a>,name,isnull((select COUNT(1) <a href="https://www.baidu.com/s?wd=from&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">from</a> b where bid=a.id),0) <a href="https://www.baidu.com/s?wd=from&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1mhwWP1IhujnYujm1njcs0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHDknj64PWmzrjcsPjfknHc4rf" target="_blank" class="baidu-highlight">from</a> a order by 3 desc
追问
您辛苦了!虽然看不懂
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询