mysql 限制指定字段的长度

屠虫录:

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  阅读(384)  评论(0编辑  收藏  举报