我的每件事都对我有Sql数据库

  NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS where (modifiedAdress) VALUES (\"%@\")", hemaInsert];


我用它来插入,但我如何调节

仅我需要表示插入到联系人列的Sql语句ModifyAdress值hemainsert (condition hemaInsert = ID )

NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS where (modifiedAdress) VALUES (\"%@\")", hemaInsert];

最佳答案

如果要插入整个行/元组/记录。

NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS where modifiedAdress is '%@'", hemaInsert];//you can go for " or ' as per oracle or other sqls.


NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS where modifiedAdress = \"%@\"", hemaInsert];//you can go for " or ' as per oracle or other sqls.


编辑:

INSERT用于添加元组(行)。如果只想在特定列插入,则需要使用UPDATE。

语法为:

UPDATE tableName
SET column1=value, column2=value2,...
WHERE some_column=some_value


采用:

NSString *insertSQL = [NSString stringWithFormat: @"UPDATE CONTACTS SET modifiedAdress  = \"%@\"", hemaInsert];

关于ios - 需要正确的SQL语句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15174987/

10-10 01:13
查看更多