SQL Query Where Column = '' returning Emoji characters

前端 未结 4 1645
半阙折子戏
半阙折子戏 2020-12-04 02:11

Ok so I have a table with three columns:

Id, Key, Value

I would like to delete all rows where Value is empty (\'\'

相关标签:
4条回答
  • 2020-12-04 02:25

    Google send me here looking for a way filter all rows with an emoji on a varchar column. In case that your looking for something similar:

    SELECT mycolumn
    FROM mytable
    WHERE REGEXP_EXTRACT(mycolumn,'\x{1f600}')  <> ''
    

    the \x{1f600} is the char code for the searched emoji, you can find the emoji codes here

    0 讨论(0)
  • 2020-12-04 02:31

    It's not an answer to your "why", but in terms of your overall goal, perhaps you should alter your strategy for searching for empty values:

    Select * from [Imaging.ImageTag] where LEN([Value]) = 0
    

    As per the comments (thanks Martin Smith for providing some copy/pastable emoji):

    SELECT CASE WHEN N'' = N'                                                                    
    0 讨论(0)
  • 2020-12-04 02:39

    This is collation dependant.

    Matches empty string

    SELECT 1 where N'' = N'                                                                    
    0 讨论(0)
  • 2020-12-04 02:41

    Complementing this answers When you need use 'like' at sql

    WHERE
    N'' + COLUMNS like N'%'+ @WordSearch +'%' COLLATE latin1_general_100_ci_as 
    
    0 讨论(0)
提交回复
热议问题