Hi, how can I pull only words with maximum 50 Characters from MYSQL?
$query = "SELECT * FROM example ORDER BY ID DESC LIMIT 200";
Hi, how can I pull only words with maximum 50 Characters from MYSQL?
$query = "SELECT * FROM example ORDER BY ID DESC LIMIT 200";
Try the length() function http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
SELECT * FROM example WHERE LENGTH(column) <= 50 ORDER BY ID DESC LIMIT 200
Try using the CHAR_LENGTH
function in a WHERE
constraint:
SELECT * FROM example WHERE CHAR_LENGTH(word) <= 50 ORDER BY ID DESC LIMIT 200
CHAR_LENGTH
returns the number of characters in the string. LENGTH
returns the number of bytes. It is prefeable to use CHAR_LENGTH
if your word could contain multi-byte characters.