mysql复杂查询sql_mysql – 复杂的SQL查询,很多很多
像這樣的東西.
Select people.id, people.name, count(interest.id)
from people
left join people_interests on people.id = people_interests.peopleid
left join interests on people_interests.interestid = interests.interest.id
where interests.id in (select id from interests where interests.peopleid = @inputuserid)
group by people.id, people.name
order by count(interest.id)
英語(可能會或可能不會更清楚.)
>選擇人員姓名和他們共享的興趣數量
>從人員表
>加入那個表的興趣表
>只是我們想要匹配的人的利益.
>(按人群分組
>并按匹配的興趣數量排序.)
更新沒有子查詢但不太清楚
Select people.id, people.name, count(interest.id)
from people
left join people_interests on people.id = people_interests.peopleid
left join interests on people_interests.interestid = interests.interest.id
inner join interest i2 on (interests.id = i2.id and i2.people_id = @inputuserid)
group by people.id, people.name
order by count(interest.id)
總結
以上是生活随笔為你收集整理的mysql复杂查询sql_mysql – 复杂的SQL查询,很多很多的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华普小汽车故障有哪些原因呢?
- 下一篇: linux cmake编译源码,linu