如果要匹配的原文是she is my,怎么让下面的数据按照匹配的多少进行排序?数据库内容:
she is my sin  she is is she
she is is she she she she sin sin
she is my sin  she is my
she is my Girl friend she
she is my Son she my
下面这个可以的,但是只能进行一个单词,3个单词该如何写?
SELECT *  
FROM sjk
ORDER BY LENGTH( REPLACE( biaoti, 'she', '' ) )  -  LENGTH( biaoti )

解决方案 »

  1.   

    ORDER BY LENGTH( REPLACE( biaoti, 'she', '' ) ) - LENGTH( biaoti )
    这个能帮我讲解下原理不? 我对sql真的不太熟,这里面的REPLACE支持正则不?
      

  2.   

    REPLACE( biaoti, 'she', '' )
    把biaoti这个字段里面的she字符替换成空LENGTH(biaoti)
    标题字段的长度
      

  3.   

    原理呢?
    如果我执行这句 ORDER BY LENGTH( REPLACE( biaoti, 'she', '' ) ) - LENGTH( biaoti )
    结果是这样排的:she 越多的数据越往前排, 我想单个单词可以这样!多个单词为什么不行呢?mysql 里的 REPLACE支持正则吗?
    she is is she she she she sin sin
    she is my sin she is is she
    she is my Girl friend she
    she is my sin she is my
    she is my Son she my
      

  4.   

    SELECT *   
    FROM sjk
    ORDER BY LENGTH( replace(replace(REPLACE( biaoti, 'she', '' ),'he',''),'they','' ) - LENGTH( biaoti ))