【问题标题】:Phonegap - Assemble with a query result from another query - Sqlite QueryPhonegap - 与另一个查询的查询结果组合 - Sqlite 查询
【发布时间】:2014-11-25 21:09:31
【问题描述】:

我无法通过第一个结果进行选择

目标是: 在“行”表上进行查询,获取您的 ID 并搜索“客户”表行的客户

这是我的代码:

    db = window.openDatabase("test", "1.0", "Test DB", 1000000);          
    db.transaction(SelectData,erroSelect,sucessSelect);

    function SelectData(tx)
    {
       tx.executeSql("select id from linha",[],function(tx, response)
       {
            for(i=0; i<response.rows.length; i++)
            {
                tx.executeSql("SELECT * FROM customers WHERE line= ?", [response.rows.item(i).id], 
                function (tx, results)
                {
                    for(r=0; r<results.rows.length; r++)
                    {
                        alert(results.rows.item(r).nome); //never worked
                    }   
                }
            }
        },SelectError);
    } 

【问题讨论】:

    标签: sqlite cordova opendatabase


    【解决方案1】:

    从您的帖子中很难理解,实际错误在哪里。
    您是否尝试过在每个 tx.executeSql() 中使用 console.log() 调用来确定函数正在执行。
    或者,您可以使用单个查询而不是使用两个 SELECT 语句。

    替换

    select id from linha
    

    SELECT customers.columnName1, customers.columnName2 
    FROM customers INNER JOIN linha ON customers.line = linha.id
    

    【讨论】:

    • 我没有使用这个,因为我需要这样的结构:第 1 行的标题 customer 1 customer 2 customer 3 第 2 行的标题 customer 4 customer 5 customer 6
    猜你喜欢
    • 2014-08-18
    • 2011-12-02
    • 1970-01-01
    • 2012-06-19
    • 1970-01-01
    • 2021-10-28
    • 2010-10-31
    • 1970-01-01
    • 2015-09-22
    相关资源
    最近更新 更多