MySQL SELECT statement for the "length" of the field is greater than 1
Solution 1:
How about:
SELECT * FROM sometable WHERE CHAR_LENGTH(LINK) > 1
Here's the MySql string functions page (5.0).
Note that I chose CHAR_LENGTH
instead of LENGTH
, as if there are multibyte characters in the data you're probably really interested in how many characters there are, not how many bytes of storage they take. So for the above, a row where LINK is a single two-byte character wouldn't be returned - whereas it would when using LENGTH
.
Note that if LINK
is NULL
, the result of CHAR_LENGTH(LINK)
will be NULL
as well, so the row won't match.
Solution 2:
select * from [tbl] where [link] is not null and len([link]) > 1
For MySQL user:
LENGTH([link]) > 1