简体   繁体   English

如果所有这些词都与 PHP 中的 SQlite3 查询匹配,则排除结果

[英]Exclude results if all this words are matched from SQlite3 query in PHP

I want to do a SQLITE3 QUERY that allows to me to exclude results that matches a specific amount of words.我想做一个 SQLITE3 QUERY,它允许我排除与特定数量的单词匹配的结果。 For example.例如。

SELECT * FROM TABLE WHERE TEXT NOT LIKE ("ONE","TWO", "THREE"); SELECT * 来自表中的文本不喜欢(“一”、“二”、“三”);

I want to exclude results only if all this words are matches.只有当所有这些单词都匹配时,我才想排除结果。 But if only "ONE" and "TWO" are matched, then do not exclude that.但如果只有“ONE”和“TWO”匹配,则不要排除它。 Also, if only one word is matched, do not exclude.另外,如果只有一个词匹配,不要排除。

I would prefer to do it with the LIKE statement我宁愿用 LIKE 语句来做

We can try using INSTR as follows:我们可以尝试如下使用INSTR

SELECT *
FROM yourTable
WHERE
    INSTR(text, 'ONE') = 0 OR
    INSTR(text, 'TWO') = 0 OR
    INSTR(text, 'THREE') = 0;

This logic returns a record if any one of ONE , TWO , or THREE be missing in the text.如果文本中缺少ONETWOTHREE中的任何一个,此逻辑将返回一条记录。

Here is the case insensitive version:这是不区分大小写的版本:

SELECT *
FROM yourTable
WHERE
    INSTR(UPPER(text), 'ONE') = 0 OR
    INSTR(UPPER(text), 'TWO') = 0 OR
    INSTR(UPPER(text), 'THREE') = 0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM