mysql don't count row twice if column data is duplicated

前端 未结 1 547
盖世英雄少女心
盖世英雄少女心 2021-01-29 12:10

I am counting the rows in a mysql table called ptb_profile_views.

My table looks like this:

id  |  profile_id   | viewed_profile_id  |  date         


        
相关标签:
1条回答
  • 2021-01-29 13:01

    Try the following (assuming viewed_profile_id is 6):

    SELECT COUNT(DISTINCT profile_id) FROM ptb_profile_views WHERE viewed_profile_id=6
    
    0 讨论(0)
提交回复
热议问题