-3

下面是我可以从数据库中搜索的代码,但我希望它使用 OR 语句而不是 AND 语句进行搜索。

var sea=$("#search").val();
var sear=$.trim(sea);
var test = sear.split(" ");
var arrDistinct = new Array(); 
$(document).ready(function() { 
    $(test).each(function(index, item) { 
        if ($.inArray(item, arrDistinct) == -1) 
        arrDistinct.push(item); 
    }); //end each
    $(arrDistinct).each(function(index, item) { 

        //database
        var db = openDatabase("Database", "1.0", "Inventory", 200000);
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM DEMO WHERE (D_Indications LIKE ?);", ["%"+item+"%"],

                for (i = 0; i < len; i++) {
                    $('#output2').append('<tr><td>'+ results.rows.item(i).Cat_name +'</td><td>'+ results.rows.item(i).Drug_Caty +'</td><td>'+ results.rows.item(i).G_Name +'</td><td>'+ results.rows.item(i).B_Name +'</td><td>'+ results.rows.item(i).D_Indications +'</td></tr>').trigger('create');

                }//end for

                });//end function


            });//end db transaction

        }); //end each function

});//document ready

当用户输入“Hello World”时,我希望它使用“%Hello%”或“%World%”搜索数据库我怎样才能用 jquery 做到这一点?

4

1 回答 1

0

如果您想了解 sqlite OR 语句Python,请参阅这篇文章:sqlite OR 语句

于 2012-08-04T09:13:36.923 回答