随笔分类 -  08 数据库

摘要:在几千条记录里,存在着些相同的记录,如何能用SQL语句,删除掉重复的呢?谢谢!1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断select*from peoplewhere peopleIdin (select peopleIdfrom peoplegroupby peopleIdhavingcount(peopleId)>1)2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录deletefrom peoplewhere peopleIdin (select peopleIdfrom peoplegroup 阅读全文
posted @ 2013-06-18 21:47 ygm900 阅读(200) 评论(0) 推荐(0)
摘要:屠虫录:1)在实际使用中,忘记在sql语句中加and导致查询不到任何结果2)在Xcode的实际使用中,sql语句被写为如下: NSString *strSqlroot = [NSStringstringWithFormat:@"select * from food_type where code like '%@%@' and length(code) > 3" ,typeCode,@"%"];注意,这个查询的范围比上面扩大到了*,%用了字符串进行替换,而不是直接写在sql语句中。 阅读全文
posted @ 2013-01-21 13:24 ygm900 阅读(393) 评论(0) 推荐(0)