【问题标题】:Get the query work with % (ajax+javascript+html)使用 % (ajax+javascript+html) 获取查询
【发布时间】:2016-11-28 04:54:09
【问题描述】:

我正在尝试获取专辑标题包含“Led”的所有结果。

使用终端,

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

这个actullay得到我需要的项目,但是,使用javascript,

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

请假设上面,document.getElementById("title").value 是“Led "

无论如何,上面关于javascript的查询不起作用。

我猜想使用 %.如何在 javascript 上使用 % 作为查询语句?

(我也不应该使用“匹配”而只使用“喜欢”,因为它不支持..)

【问题讨论】:

    标签: javascript sql ajax sqlite


    【解决方案1】:

    我不知道您使用的是什么包装器,但您可以在绑定参数中绑定通配符%%

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

    https://jsfiddle.net/9d8tpve5/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-13
      • 2020-04-05
      • 2016-01-28
      • 1970-01-01
      • 2021-03-17
      • 2017-09-13
      • 1970-01-01
      • 2016-06-15
      相关资源
      最近更新 更多