2016-11-28 57 views
0

我試圖獲取其專輯標題包含「Led」的所有結果。獲取查詢使用%(ajax + javascript + html)

使用終端,

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

這actullay得到我需要的項目,但是,使用JavaScript,

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

請assum以上,的document.getElementById( 「標題」)。值「Led 」

無論如何,上面的JavaScript查詢不起作用。

我想在使用%有問題。我如何在查詢語句上使用JavaScript上的%?

(也是我不應該使用「匹配」,但只有「喜歡」,因爲它不支持..)

回答

1

我不知道你使用的是什麼包裝,但你可以在綁定參數綁定通配符%%

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

https://jsfiddle.net/9d8tpve5/