Forum Moderators: coopster
Here's my query: "SELECT * FROM blogs LEFT JOIN comments ON blogs.blog_id = comments.blog_id ORDER BY blogs.blog_id DESC LIMIT 15"
That's getting me the last 15 rows, but I really want the last 15 blogs and their comments. I'll explain better- if I have 1 blog with 15 comments, that query is getting me the 15 comments joined with the one blog. What I'm wanting to do is get the last 15 blogs and those comments. So, I really don't know how many rows I need, but I only want 15 blogs.
Eh, hopefully that's clear enough. I know that I can do that with 2 SQL statements, but where's the fun in that? :) Really I just wish I could move the LIMIT statement somehow. Any help is appreciated.
shure that would be fun to do in one query. but join creates internally a new table containing all the fields joined. so LIMIT is only able to perform on that table.
perhaps you can use expressions in LIMIT but COUNT so far does only work with GROUP BY and that's not useable with JOIN i think. that's what i've got so far.
-hakre
Anyway, for now I'm cheating- I'm pulling a ton more than I really need and just using the first 15 that I really want, skipping the entries that don't fit my criteria.
Thanks for the suggestion. I'll post back here if/when I find the solution.