0
我有一個工作的SELECT語句。不過,我想補充一點。我想使它匹配所需的匹配數量,直接對應於'input'列的char_length。因此,舉例來說:使所需的匹配數量直接對應列的char_length
if (char_length(input) <= 5) { matches required is 1 }
if (char_length(input) > 5 && char_length(input) <= 10) { matches required is 2 }
if (char_length(input) > 10 && char_length(input) <= 15) { matches required is 3 }
and ect...
如何添加^^^,爲下面的SELECT語句?
$text = "one";
$textLen = strlen($text);
SELECT response, (input LIKE '% $text %') as matches
FROM allData
WHERE (char_length(input) >= '$textLen'-($textLen*.1)
AND char_length(input) <= '$textLen'+($textLen*.1))
HAVING matches > 0
AND matches = (select max((input LIKE '% $text %')) from allData) limit 30;
它不起作用。它和以前一樣工作,沒有額外的變化。 http://stackoverflow.com/questions/32704222/selecting-matches-according-to-the-char-length-of-the-strings-in-rows?noredirect=1#comment53253000_32704222請看看這個問題。我已經用你的例子重新提出了這個問題,並增加了更多的細節。 – jessica