這裏是PhoneGap的Android的表:查詢 「COALESCE」 SQLite中
tx.executeSql( 「CREATE TABLE IF NOT EXISTS user_prayers( '身份證' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE 'prayer_id' TEXT,'user_id' INTEGER,'date'DATETIME,'status'INTEGER)「,[],successCB,errorCB);
,並通過使用循環插入行:
function insertInUserPrayerTable() {
db.transaction(function(tx)
{for(var i = 0;i<5;i++)
{checkedValueofCheckboxInsertArray.push('INSERT INTO user_prayers '
+ '(prayer_id,user_id,date,status)'
+ ' VALUES("'
+ checkedValueofCheckbox[i]
+ '","'
+ window.localStorage
.getItem("userid") + '","'
+ $('#datepicker').val() + '","'
+ statusofNamaz[i] + '");');
console.log("array values:"+checkedValueofCheckboxInsertArray);
}
},errorCB,successCB);
runInsertQuery();
}
function runInsertQuery() {
db
.transaction(
function(tx) {
for (var i = 0; i < checkedValueofCheckboxInsertArray.length; i++) {
tx
.executeSql(
checkedValueofCheckboxInsertArray[i],
[],
successCBrunInsertQuery,
errorCBrunInsertQuery);
}
},errorCB,successCB);
}
$('#showbtn')
.off('click')
.on('click',
function() {
//getRecord();
db
.transaction(
function(tx) {
tx.executeSql("SELECT a.date, COALESCE(a.status,'') AS 'fajr', COALESCE((SELECT b.status FROM user_prayers b WHERE b.date = a.date AND b.id != a.id LIMIT 1),'') AS 'zohar' FROM user_prayers a WHERE user_id='"+window.localStorage.getItem("userid")+"' GROUP BY a.date",[],successCBofselect,errorCBofselect);},errorCB,successCB);
但它沒有返回我的狀態,而相同的查詢工作正常,在SQL小提琴:
你忘了粘貼sql小提琴? – 2013-05-09 06:45:28
sql小提琴不保存我的小提琴多數民衆贊成那就是爲什麼不在這裏發佈 – nida 2013-05-09 06:58:54