mysql 限制指定字段的长度

屠虫录:

1)在实际使用中,忘记在sql语句中加and导致查询不到任何结果

2)在Xcode的实际使用中,sql语句被写为如下:

 NSString *strSqlroot = [NSStringstringWithFormat:@"select * from food_type where code like '%@%@' and length(code) > 3" ,typeCode,@"%"];

注意,这个查询的范围比上面扩大到了*,%用了字符串进行替换,而不是直接写在sql语句中。 

原文地址:https://www.cnblogs.com/ygm900/p/2869605.html