如何在mysql中获得没有大于40个字符的单词的列?

Mic*_*ina 3 php mysql character cpu-word

基本上,我正在尝试在php中创建一个函数,它将为我提供最新的列(消息),其中没有超过40个字符的单词.我能够获得最新的消息,但我不知道如何只获取没有大于40个字符的单词的最新消息.请参考$ callrecent变量.

<?php
function recentpost($postnum) {
$callrecent = "SELECT message FROM messages WHERE message (HAS NO WORD GREATER THAN 40 CHARACTERS) ORDER BY msg_id DESC LIMIT $postnum,1";

$callrecent_run = mysql_fetch_assoc(mysql_query($callrecent));

$message = stripslashes($callrecent_run['message']);

return $message;
}
?>
Run Code Online (Sandbox Code Playgroud)

Gry*_*ius 6

你可以使用正则表达式

SELECT message
FROM messages
WHERE message not regexp '[[:alnum:]]{41}'
ORDER BY msg_id DESC
LIMIT $postnum, 1
Run Code Online (Sandbox Code Playgroud)