dimanche 14 juin 2015

Updating using innerjoin sqlite ios

Right now I am updating the two Tables(EMPLOYEE & DEPARTMENT) based on the values which I am passing. There exists a common empID in both tables. but my update query is not working. Here is my query:-

 NSString * insertSQL  = [NSString
 stringWithFormat:@"UPDATE EMPLOYEE SET empName= %@ ,empdesignation=%@ where EXISTS FROM EMPLOYEE INNER JOIN DEPARTMENT EMPLOYEE.empID=DEPARTMENT.empID where EMPLOYEE.empID=%@",_txtName.text,_txtEmpDesg.text,_txtfind.text];

                NSLog(@"update query is%@",insertSQL);
        const char *insert_stmt = [insertSQL UTF8String];
        sqlite3_prepare_v2(database, insert_stmt,-1, &statement, NULL);
        if (sqlite3_step(statement) == SQLITE_DONE)
        {
            NSLog(@"update done");
        }
        else {
            NSLog( @"Error while updating '%s'", sqlite3_errmsg(database));

        }
        sqlite3_reset(statement);
        sqlite3_close(database);

    }

It says:Error while updating 'near "FROM": syntax error'. Please tell me the correct update query for the problem. thanks

Aucun commentaire:

Enregistrer un commentaire