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'都搜索不出来。这是什么原因呢?有什么办法能让不管有没有空格,都能搜索出来呢? 展开
 我来答
wP3m15g
2016-06-01 · TA获得超过262个赞
知道小有建树答主
回答量:290
采纳率:0%
帮助的人:165万
展开全部
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
追问
您辛苦了!虽然看不懂
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式