Personal reports. Conclusion of dialogues



  • There are two tables.

    [users]
    
    • id
    • name

    [prmess]

    • id
    • date
    • from_id
    • to_id
    • text
    • view (boolean) 1/0

    In fact, there are no problems with the conclusion of this particular dialogue/addition of communications, etc. There is a problem with the withdrawal of the list of dialogues. I mean, from me to the loop, and from the petition to me, it's one dialogue, and how to make a request like that? It's more important to sum up unreaded messages (view) in this dialogue only from an interviewer (excluding his own).
    There's got to be something like,

    1. Negotiator [Peta], unreaded communications [2], id interviewer. =2
    2. Negotiator [all], unreported [5], id interviewer.=3
    3. Negotiator [January], unreported [0], id interviewer.=4
    4. Negotiator [Cole], unreaded communications [1], id interviewer.=5


  • select name,sum(not_view) msg_cnt,int_id
      from (
            select if(from_id=1,to_id,from_id) int_id, 1-view not_view
              from prmess
             where from_id=1 or to_id=1
           ) A
      join users2 on id=int_id
     group by int_id
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2