如何删除sqlite数据库表中的行? [英] How to delete a row in a sqlite database table?

查看:137
本文介绍了如何删除sqlite数据库表中的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用fmdb来管理我的数据库。我找不到任何从fmdb中的表中删除行的示例。我试过

I am using fmdb for managing my database. I could not find any example for deleting a row from a table in fmdb. I tried

  NSString *sqlStat=@"DELETE from tableName WHERE id=3";    
  FMResultSet *rs = [database executeQuery:sqlStat];

但它没有用,因为当我检查表中的条目总数时,我得到的相同执行上述语句之前的数字。
那么,使用fmdb从表中删除行的正确方法是什么?

but its not working because when I checked the total number of entries in table, I am getting the same number as before executing the above statement. So, what is a proper way to delete a row from a table using fmdb?

推荐答案

FMDB可以是一个如果你没有作为NSNumber传递对象,那就很挑剔。这是格式化查询的受支持且安全的方式。

FMDB can be a little finicky if you dont pass in the object as an NSNumber. This is the supported, and safe way of formatting queries.

[db executeUpdate:@"DELETE FROM theTable WHERE id = ?", [NSNumber numberWithInt:myObject.id]];

这篇关于如何删除sqlite数据库表中的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆