0

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=%@  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

The solution which I saw update only a single table and values are coming form the other table. But in my case I am updating two tables in parallel based upon the 'empid' which the user is passing. I dont know how to solve the problem. So if anyone know the solution then please let me know.

Prakash
  • 157
  • 10

0 Answers0