Domanda

this.db.transaction(function (tx)
            {
                tx.executeSql('SELECT tsk.*, cont.firstName, cont.lastName ,cont1.firstName, cont1.lastName, list.listId FROM tbl_tasks tsk, tbl_contacts cont,tbl_contactequests cont1, tbl_lists list WHERE  (tsk.assignedId=0 or tsk.assignedId=cont.contactId or tsk.assignedId=cont1.contactRequestId) and tsk.taskCategoryType != "INBOX_NOT_ACCEPTED" and list.listId=tsk.listId and list.listId='+window.defaultlistid+' group by tsk.taskId', [], enyo.bind(this,this.queryResponse), enyo.bind(this,this.errorHandler));//call queryResponse
            }.bind(this));

Ora, come potete vedere cont.firstName (tbl_contacts tabella) e cont1.firstName ha (tbl_contactequests tabella) ha stessi campi Nome

for (var i = 0; i < len; i++)
            {

                list[i]     =   results.rows.item(i);
                fname       =   list[i].firstName;
                lname       =   list[i].lastName;
                fullname    =   fname+' '+lname;
                //alert(fullname);
                if(list[i].assignedId==0)
                {list[i].name = '';}
                else
                {list[i].name=fullname;}

            }

con questo ciclo posso in grado di featch primo valore del campo tbl_contacts firstname.Now supporre se non riesco ad accedere tbl_contactequests tavolo cognome.

È stato utile?

Soluzione

Usa parole chiave AS per la query SQL:

    'SELECT tsk.*, 
            cont.firstName AS cFirstName, 
            cont.lastName ,
            cont1.firstName AS c1FirstName, 
            cont1.lastName, list.listId 
     FROM tbl_tasks tsk, tbl_contacts cont,
          tbl_contactequests cont1, tbl_lists list 
     WHERE  (tsk.assignedId=0 OR tsk.assignedId=cont.contactId OR
            tsk.assignedId=cont1.contactRequestId) AND 
            tsk.taskCategoryType != "INBOX_NOT_ACCEPTED" AND 
            list.listId=tsk.listId AND list.listId='+window.defaultlistid+' 
     GROUP BY tsk.taskId'
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top