我想統計單個用戶發送和接收的來自其他單個用戶的最大消息數。我不明白如何實現這一點。卡在mysql查詢中
Example for 3 messages exchanged:
[1] John(1472) msg Jane
Jane msg John(1472)
[2] John(1472) msg Jane
Jane msg John(1472)
[3] John(1472) msg Jane
OR
[1] John(1472) msg Jane
Jane msg John(1472)
[2] John(1472) msg Jane
Jane msg John(1472)
[3] John(1472) msg Jane
Jane msg John(1472)
OR
[1] John(1472) msg Jane
John(1472) msg Jane
John(1472) msg Jane
Jane msg John(1472)
[2] John(1472) msg Jane
John(1472) msg Jane
Jane msg John(1472)
Jane msg John(1472)
[3] John(1472) msg Jane
Jane msg John(1472)
所有上述實施例將給出這兩個用戶之間交換的3個消息。我的表結構是這樣的:http://sqlfiddle.com/#!9/f84f17/1
每次用戶向另一個用戶發送一條消息,我們在不同的senderid,receiverid,所有者和文件夾(收件箱/發送)的郵箱表中插入兩行。
你爲什麼使用這樣複雜的structure.Just有4列,如senderId,receiverId,消息,狀態 其中狀態表示消息是由用戶成功發送還是由用戶接收。 –
表結構不是由我創建的。這已經是項目,我必須爲它生成報告。 :)該網站使用osDate框架。 – munjal
然後運行查詢,如WHERE senderid ='1472'AND recipientid ='338' –