Sqlite: multiple update (find and replace) case insensitive

后端 未结 2 1884
星月不相逢
星月不相逢 2021-01-21 15:10

I use DB Browser for SQLite to visualize and update an sqlite file.

I am able to do run a case sensitive query to update some text like this:

UPDATE ite         


        
2条回答
  •  耶瑟儿~
    2021-01-21 15:33

    You need to search substring in LOWER(note), but replace it in original. I don't know where you getting sometext from, assume that you can check it's length. In following example I'll use constant.

    UPDATE itemNotes  
    SET 
      note = SUBSTR(note, 0, INSTR(LOWER(note), 'sometext')) || 'abc' || SUBSTR(note, INSTR(LOWER(note), 'sometext')+sometext_len)
    WHERE 
      INSTR(LOWER(note), 'sometext') >= 0;
    

    !Note: It will work only for one replace at a time.

提交回复
热议问题