How do I add multiple "NOT LIKE '%?%' in the WHERE clause of sqlite3?

前端 未结 7 2105
无人及你
无人及你 2020-12-23 20:06

I have a sqlite3 query like:

SELECT word FROM table WHERE word NOT LIKE \'%a%\';

This would select all of the words where \'a\' does not oc

相关标签:
7条回答
  • 2020-12-23 20:11

    this is a select command

       FROM
        user
    WHERE
        application_key = 'dsfdsfdjsfdsf'
            AND email NOT LIKE '%applozic.com'
            AND email NOT LIKE '%gmail.com'
            AND email NOT LIKE '%kommunicate.io';
    

    this update command

     UPDATE user
        SET email = null
        WHERE application_key='dsfdsfdjsfdsf' and  email not like '%applozic.com' 
        and email not like '%gmail.com'  and email not like '%kommunicate.io';
    
    0 讨论(0)
  • 2020-12-23 20:11

    If you have any problems with the "not like" query, Consider that you may have a null in the database. In this case, Use:

    IFNULL(word, '') NOT LIKE '%something%'
    
    0 讨论(0)
  • 2020-12-23 20:13

    You missed the second statement: 1) NOT LIKE A, AND 2) NOT LIKE B

    SELECT word FROM table WHERE word NOT LIKE '%a%' AND word NOT LIKE '%b%'
    
    0 讨论(0)
  • 2020-12-23 20:24

    The query you are after will be

    SELECT word FROM table WHERE word NOT LIKE '%a%' AND word NOT LIKE '%b%'
    
    0 讨论(0)
  • 2020-12-23 20:28
    SELECT word FROM table WHERE word NOT LIKE '%a%' 
    AND word NOT LIKE '%b%' 
    AND word NOT LIKE '%c%';
    
    0 讨论(0)
  • 2020-12-23 20:36

    If you use Sqlite's REGEXP support ( see the answer at Problem with regexp python and sqlite for how to do that ) , then you can do it easily in one clause:

    SELECT word FROM table WHERE word NOT REGEXP '[abc]';
    
    0 讨论(0)
提交回复
热议问题