-1
的獨特組合僅排我的影片獲取的結果就像一個SQL查詢:選擇有兩列
[{"id":89,"sender_id":2,"reciever_id":1,"message":"no reply","deleted_at":null,"created_at":"2017-04-04 17:01:20","updated_at":"2017-04-04 17:01:20"},
{"id":88,"sender_id":1,"reciever_id":2,"message":"hiiiii","deleted_at":null,"created_at":"2017-04-04 16:59:47","updated_at":"2017-04-04 16:59:47"},
{"id":87,"sender_id":5,"reciever_id":1,"message":"hiiiii","deleted_at":null,"created_at":"2017-04-04 16:59:43","updated_at":"2017-04-04 16:59:43"},
{"id":86,"sender_id":1,"reciever_id":5,"message":"hiiii","deleted_at":null,"created_at":"2017-04-04 16:59:38","updated_at":"2017-04-04 16:59:38"},
{"id":85,"sender_id":1,"reciever_id":5,"message":"hiii vRUN\n","deleted_at":null,"created_at":"2017-04-04 16:10:51","updated_at":"2017-04-04 16:10:51"}]
但我想的sender_id
和reciever_id
只有獨特的組合。我只需要5行中的2行,因爲只有2行有獨特的組合。像這樣:
[{"id":89,"sender_id":2,"reciever_id":1,"message":"no reply","deleted_at":null,"created_at":"2017-04-04 17:01:20","updated_at":"2017-04-04 17:01:20"},
{"id":87,"sender_id":5,"reciever_id":1,"message":"hiiiii","deleted_at":null,"created_at":"2017-04-04 16:59:43","updated_at":"2017-04-04 16:59:43"},
我該如何做到這一點?
兩者有什麼區別? –
請更新您的查詢 –
1-分組標準是什麼 2-除非您使用像SUM(),MAX()這樣的集合函數,否則您不能像這樣對列進行分組。3-我確定這個問題已經在這個網站回答 –