简体   繁体   中英

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

I am trying to get all the results where its album title contains "Led".

using terminal,

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

this actullay get the item I need, however, using javascript,

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

Please assum that above, document.getElementById("title").value is "Led "

Anyway, above query on javascript doesn't work.

I guess there is problem on using %. How can I use % on javascript for a query statement?

(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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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