任何人都可以讓我知道什麼MI做錯了.....INSERT WITH SELECT查詢在SQLITE中給我的語法錯誤?
這裏是我的查詢,並試圖運行SQLite數據庫管理查詢,以及它的執行過程中總是進入"errorfunction"
當越來越語法錯誤"near SELECT"
在PhoneGap的應用
tx.executeSql("INSERT INTO proposal_products(proposal_id,date_created,date_modified,labour_hours,cost_price,sale_price,adj_cost_price,adj_sale_price,service_price,adj_service_price,discipline_products_id) VALUES("
+ window.localStorage
.getItem("assign_proposal_id")
+ ",'"
+ getCurrentDateTime()
+ "','"
+ getCurrentDateTime()
+ "',"
+ selectedLabourHours
+ ","+ callStd +","
+ callStd +","
+ callStd +","
+ callStd +","
+ callStd +","
+ callStd +",(SELECT id FROM discipline_products WHERE discipline_products.product_id = (SELECT id FROM products WHERE c4w_code = "CALSTD")))",
[],
function() {
console
.log("suceessCBinsertIntoProposalProduct when Checkbox unchecked:");
window.localStorage.setItem("discipline_product_idCallStd","discipline_IdCallSTD");
},
function(err) {
console
.log("errorCBinsertIntoProposalProduct when Checkbox unchecked:"
+ err.message);
});
首先要解決:*不建立SQL像*。使用準備好的語句。它將使得更容易看到語法錯誤*並*它將保護您免受轉換錯誤和SQL注入攻擊。 –
請參閱'SELECT ID FROM products WHERE c4w_code =「CALSTD」'而不是它應該是'SELECT ID FROM products WHERE c4w_code =「+ CALSTD +」' – CRUSADER
@jon它的sqlite查詢不是sql – nida