我有兩列(film_id,actor_id),我需要找到一對演員,使電影中最多的相互出現,例如演員10和演員20一起有兩部電影(1 ,3),所以我需要回到10,20SQL發現最大的相互出現
0
A
回答
0
不知道這是什麼,你到底要或沒有,但嘗試它:
select
group_concat(actor_id) as actors
from (
select actor_id, group_concat(movie_id order by movie_id) as movies
from tbl1
group by actor_id) t1
group by movies
having count(actor_id) = 2
+0
hmm。我試着運行它,我得到零行返回,但「有」標籤是deffenlty一個很好的aproche,我會谷歌它有點:) –
+0
但我用你的sqlfiddle鏈接和它的工作,所以也許我的mySql錯誤? –
0
您可以group by
可能沿着使用group_concat()
像
select group_concat(actor_id) as multistarter
from movies
group by movie_id;
相關問題
- 1. 發現互相關最大的滯後ccf()
- 2. PHP發現最大
- 3. 發現最大點擊
- 4. 推力CUDA發現最大
- 5. 如何發現相互行會?
- 6. 最大出現次數
- 7. C#,ListView圖標互相出現
- 8. 發現大多數出現在多個列中SQL
- 9. SQL查詢發現最常水平出現
- 10. 相互信息的實現
- 11. 發現最大數據包大小
- 12. 在SQL Server中的varbinary(最大值)的最大現實空間
- 13. 發現字典中最大的價值
- 14. 發現最大的分之前來到
- 15. 發現的最大值和陣列
- 16. 發現最大的MySQL時柱爲varchar
- 17. 發現對應的值最大
- 18. 列中出現最大值的頻率
- 19. 計算出現的最大數
- 20. SQL查詢來發現的最大一組平均
- 21. 的Sql精簡版最大不發現列名
- 22. SQL,如何提取最大出現次數的條目
- 23. SQL:每個值的最大出現次數
- 24. 發生的最大數目的字符出現在字符串
- 25. SQL,最頻繁出現的值
- 26. 在OpenAL中發現最大增益
- 27. prolog遞歸發現最大節點
- 28. 熊貓發現最大穩定間隔
- 29. 打印列其中發現最大值
- 30. 發現其中有最大文本
你能設置的結構和一些數據http://sqlfiddle.com/? –
我上傳了一張圖片,希望它能讓事情變得更容易 –
它太大了無法處理,但是從這裏下載sakila db https://dev.mysql.com/doc/index-other.html –