[英]Phonegap - Assemble with a query result from another query - Sqlite Query
I can not make a selection via the result of the first 我无法通过第一个结果进行选择
Goal is: Do the query on the table "line" pick up your ID and search customers that line the "customer" table 目标是:在“行”表上进行查询以获取您的ID并搜索在“客户”表上行的客户
This is my code: 这是我的代码:
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);
}
It is diffcult to understand from your post, where is the actual error. 从您的帖子中很难了解实际错误在哪里。
Have you tried using console.log() call inside each tx.executeSql() to ascertain that the function is being executed. 您是否尝试过在每个tx.executeSql()内部使用console.log()调用来确定该函数正在执行。
Alternatively you can use a single query instead of using two SELECT statements. 或者,您可以使用一个查询而不是使用两个SELECT语句。
Replace 更换
select id from linha
with 与
SELECT customers.columnName1, customers.columnName2
FROM customers INNER JOIN linha ON customers.line = linha.id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.