Welcome Guest, Not a member yet? Register   Sign In
Can't figure this out...
#2

[eluser]GSV Sleeper Service[/eluser]
you'll have to join the two tables. something like this should work (no promises, this is off the top of my head, plus it's friday night, I'm stoned :/)
Code:
select a.*,count(c.id) as num_comments
from article a
left join article_comments c on a.id = c.articleid
group by a.id
order by num_comments
that group by is probably wrong, try it out and see how you get on.


Messages In This Thread
Can't figure this out... - by El Forum - 11-28-2008, 11:30 AM
Can't figure this out... - by El Forum - 11-28-2008, 01:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB