简体   繁体   English

使用%获取查询工作(ajax + javascript + html)

[英]Get the query work with % (ajax+javascript+html)

I am trying to get all the results where its album title contains "Led". 我正在尝试获取所有专辑标题包含“ Led”的结果。

using terminal, 使用终端,

select * from collection where album like '%Led%';

this actullay get the item I need, however, using javascript, 这个actullay得到我需要的物品,但是,使用javascript,

access("select album from collection where album like '%" + document.getElementById("title").value + "%'", findCallback);

Please assum that above, document.getElementById("title").value is "Led " 请假设上面的document.getElementById(“ title”)。value为“ Led”

Anyway, above query on javascript doesn't work. 无论如何,以上关于javascript的查询均无效。

I guess there is problem on using %. 我猜在使用%时有问题。 How can I use % on javascript for a query statement? 如何在JavaScript上对查询语句使用%?

(also I should not use "match" but only "like" because it doesn't support..) (同样,我不应该使用“匹配”,而只能使用“喜欢”,因为它不支持..)

I don't know what wrapper you are using but you can bind wildcards %% in binding parameter 我不知道您使用的是什么包装器,但是您可以在绑定参数中绑定通配符%%

access("select album from collection where album like ?",['%'+ document.getElementById("title").value.toString() +'%'], findCallback);

https://jsfiddle.net/9d8tpve5/ https://jsfiddle.net/9d8tpve5/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM