Page 1 of 1
Help:Query
Posted: Sun Aug 21, 2005 7:10 am
by raghavan20
I have a got a table named RssFeeds_tbl
structure:
id
description
title
link
category
source
date
now I want to generate RSS feed from this table, wot I want to do is
lets assume there n,m,p rows for each source s1, s2,s3...
1. select 2 items from each source s(i)
2. complex side, select 2 items from s(1), select 3 items for s(2), select 5 items for s(3)
3. It should be the most recent RSS feed, the last one, if sources compiled once in half an hour
how do I do this???
I think
1. select all records by comparing each with other on time and prune the number of records with the recently generated records
2. from the result above I think again groupby statement anyway.
I can do all these by loops but I have to crack this in a single sql if possible...
suggestions appreciated

Posted: Sun Aug 21, 2005 9:00 am
by feyd
you're not making a whole lot of sense, but I'd say, it's not advisable to perform all that functionality in a single query, or rather, do a lot of that logic in php.
side note: using "help," "please," and "problem" in a thread's subject doesn't really help us know the actual subject of the thread since nearly 100% of threads on this site are requesting help in some form.
Posted: Sun Aug 21, 2005 11:00 am
by raghavan20
I will try to explain that again
i am getting rss feeds from various sources
each source might generate a rss feed consisting some number of 'items' in it.
I read rss feeds from various sources and load all of those 'items' into mysql.
later, i want to read a constant number of items from each source and form into a rss feed
for the complex side, i might want to take 2 items from one source, 3 from items from other and 10 items from other.
also, i get new rss feeds from these sources for every half an hour so i want to take only the latest ones.
I can do this all by php logic but wondering whether the same can be implemented by far less queries.
regd the side note feyd, i could not think of a better title as the problem at hand can not be explained in the title.
thanks for your concern guys
Posted: Sun Aug 21, 2005 11:12 am
by feyd
you can retrieve the items in a single query. You cannot restrict how many each source returns very easily (when variable) outside of using a UNION. Your query will get very large if you start using UNIONs to get specific amounts from each source. I find it best to do that particular logic in php since it can be a lot more fluid in its filtering.
As for getting the latest only, you may need to store the timestamp when a particular feed was grabbed, this will allow you to order and group the results correctly..
As for the side note, it wasn't solely directed at you, but more to remind members the title needs to be more of an actual summary of the issue at hand. Although a lot of your threads do start with "Help:"

Posted: Sun Aug 21, 2005 11:24 am
by nielsene
feyd wrote:
As for the side note, it wasn't solely directed at you, but more to remind members the title needs to be more of an actual summary of the issue at hand. Although a lot of your threads do start with "Help:"

I know we have a link somewhere to the the "How to report a bug" by ESR; its true for help requests as well.
While many people immediately turn to the forum when they get stumped, its extremely useful to make your post as "complete" as possible. Think about the problem, come up with a good title, even if it means thinking a few minutes. Outline what you're doing, what the problem is, and what other solutions you've tried. Often you'll find that suddenly you can answer your own question, or you realize that you should try "something else" before you ask for help, just in case that fixes it, etc.
I know I've probably written about twice as many posts as I've actually posted -- In the process of composing I think, "Well I should test 'foo' before I ask, because otherwise I'll look stupid". and what do you know... 'foo' fixed it.
Posted: Sun Aug 21, 2005 11:29 am
by raghavan20
thats true nielsene, thanks for your suggestions
