Question

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));

Now as you can see cont.firstName (Table tbl_contacts) & cont1.firstName has (Table tbl_contactequests) has same fields first name

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;}

            }

with this loop i can able to featch first value of tbl_contacts field firstname.Now suppose if i can't to access tbl_contactequests table firstname.

Was it helpful?

Solution

Use AS keyword for SQL query:

    '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'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top