开发者

MySql find all rows where data contains less than four characters

开发者 https://www.devze.com 2022-12-16 20:23 出处:网络
How would I properly write this sql-english query: \"SELECT zip FROM tblContacts WHERE [the number of characters in zips is less o开发者_如何学Gor equal than 4]\".

How would I properly write this sql-english query:

"SELECT zip FROM tblContacts WHERE [the number of characters in zips is less o开发者_如何学Gor equal than 4]".

Thanks.


Assuming zip is a string:

WHERE CHAR_LENGTH(zip) <= 4

should work.

Edit: originally there was some confusion as to whether the desired comparison was <, <=, or >, but now the Q's been edited to clarify, so I've edited my A accordingly.


SELECT zip FROM tblContacts WHERE CHAR_LENGTH(zip) > 0


I'm sure there must be a better way, but...:

SELECT zip FROM tblContacts WHERE zip LIKE '_' OR zip LIKE '__' OR zip LIKE '___' OR zip LIKE '____';
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号