//监测数据库中我要需要的表是否已经存在
	NSString *existsSql = [NSString stringWithFormat:@"select count(name) as countNum from sqlite_master where type = 'table' and name = '%@'", @"Member" ];
	FMResultSet *rs = [membersDB executeQuery:existsSql];
	
	if ([rs next]) {
		NSInteger count = [rs intForColumn:@"countNum"];
		NSLog(@"The table count: %li", count);
		if (count == 1) {
			NSLog(@"存在");
			return;
		}
}

 

//检测某个数据是否存在
FMResultSet *rs =[membersDB executeQuery:@"SELECT COUNT(Name) AS countNum FROM Member WHERE Name = ?",self.nameTextField.text]; while ([rs next]) { NSInteger count = [rs intForColumn:@"countNum"]; if (count > 0) { //存在 } else { //不存在 } }

 

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案