Count the number of occurrences of a string in a VARCHAR field?

后端 未结 7 1254
花落未央
花落未央 2020-11-22 07:51

I have a table like this:

TITLE          |   DESCRIPTION
------------------------------------------------
test1          |   value blah blah value
test2              


        
7条回答
  •  醉梦人生
    2020-11-22 08:38

    This should do the trick:

    SELECT 
        title,
        description,    
        ROUND (   
            (
                LENGTH(description)
                - LENGTH( REPLACE ( description, "value", "") ) 
            ) / LENGTH("value")        
        ) AS count    
    FROM 

    提交回复
    热议问题