![]() |
Most active query
Hello. I have a problem and i cant find solution i have this query:
Code:
SELECT st.id,st.typ_statusu,st.blog_nadpis_slug,st.nick,st.status,st.youtube,st.shared_from_id,st.image_big,st.time,tu.profile_picture_statuses as profilovka,But my problem is: I need to remake the query to not only count likes... but also count comments from another table! And then order them. I absolutly lost... I tried something like this but this is junk: Code:
SELECT st.id,st.typ_statusu,st.blog_nadpis_slug,st.nick,st.status,st.youtube,st.shared_from_id,st.image_big,st.time,tu.profile_picture_statuses as profilovka,likes: collum with status_id(which is ID of status from status table...) comments: the same system. IF SOMEONE COULD HELP I WOULD BE REALLY GLAD! :/ |
So noone know how to do it? :/ :P
|
Have you tried a subquery on the new counter field?
|
Quote:
But maybe there is another way... what i need is to select statuses from 24h back to example. And i need to order them by MOST ACTIVE (so sum the top liked and top commented ) and order :/ |
try to change
COUNT(co.id) to COUNT(distinct co.id) In your second query, that might make it do a thing, doh I don't guarantie nothing. |
Note allso: INNER is useless, exact same thing will be in result if you don't use it at all.
Doesnt look like you are familiare with LEFT JOIN. Note that that would show you allso records where there is no comments at all. |
Quote:
|
| All times are GMT +1. The time now is 07:47 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.