Моя база данных содержит 2 столбца, такие как Имя, PhoneNumber.
Name PhoneNumber
Sam 123
John 456
Sam XXX.. (I want to update the phone number as 789).
- Through UPDATE statement if I try to update the phone number for SAM as "789"
by verifying the name then in the entire database wherever SAM is present it
is getting modified.
- My aim is to modify in the last row which contains the name as 'Sam'.
Есть ли способ обновить номер телефона в последней строке, если имя совпадает.
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
int main()
{
char *sql = NULL, *pName = "SAM";
int rc, phno = 789;
asprintf(&(sql), "UPDATE table set PhoneNumber = %d WHERE Name = '%s'"
, phno, pName);
rc = sqlite3_exec(db, sql, NULL, 0, &zErrMsg);
if (rc != SQLITE_OK )
{
printf("Error: %s:Unable to ALTER the table\n", zErrMsg);
}
}