duanji9378
2014-06-27 08:18
浏览 52
已采纳

count在单行中用逗号分隔的唯一ID

i have the following details in mysql as

   user_id                  follow_user_id                                                    
   1                      2,3,3,3,3
   5                      1,2,3,3,3,3
   6                      1,2,3,3,3,3  

i write the following code to get the unique code as follow:

SELECT LENGTH( follow_user_id ) - LENGTH( REPLACE( follow_user_id, ',', '' ) ) +1 AS no_of_follow FROM follow WHERE user_id =1;

but it provide the result :6 i need exactly unique rows: i.e:4

plz help me thanks & regards in advance

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

相关推荐 更多相似问题