如果我将每个(一次一个)放在相同的代码中,第二个会将标题更新为 var testTitle,第一个不会删除与 WHERE 匹配的行/项目。
function deleteTableAItem(e) {
var db3 = Ti.Database.open('thedatabase');
var getTheID = db3.execute('SELECT ID FROM tableA WHERE myIndexColumn=?', e.itemIndex);
var theID = getTheID.fieldByName('ID');
Ti.API.info(tableLinkRef + " " + theID); //they match as intended
var testTitle = "DID I CHANGE?";
db3.execute('DELETE FROM tableB WHERE tableLinkRef=? AND tableARef=?',theID,theTableAItemClicked); // fixed by adding another comparison.
//db3.execute('UPDATE tableB SET titleColumn=? WHERE tableLinkRef=?',testTitle,theID); // this DOES update the titleColumn in matching rows/items when the code is active and the previous is commented out
db3.execute('DELETE FROM tableA WHERE myIndexColumn=?', e.itemIndex); //this deletes the row from the first table. I want to delete the rows I have associated in tableB as well
db3.close();
}
最佳答案
代码中的 DELETE sql 看起来不错。您可以打印出整个生成的 SQL,看看它是否真的正确,或者看看 sql 是否返回任何错误。
关于javascript - SQL 删除未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24724554/