Re: [PHP-DB] Join on single table

2005-02-12 Thread Matthew Weier O'Phinney
* Micah Stevens <[EMAIL PROTECTED]>: > What kind of speed do you need? I was aiming at something that would run in 2 hours or so. Currently, it takes around 3 - 4. > I had to go to temp tables for a logging application, but not until my > table got upwards of a million records or so.. For the n

Re: [PHP-DB] Join on single table

2005-02-11 Thread Micah Stevens
What kind of speed do you need? I had to go to temp tables for a logging application, but not until my table got upwards of a million records or so.. For the numbers your quoting, it should be pretty quick unless your engine needs optimization.. On Friday 11 February 2005 11:56 am, Matthew

Re: [PHP-DB] Join on single table

2005-02-11 Thread Matthew Weier O'Phinney
* Micah Stevens <[EMAIL PROTECTED]>: > Sounds like a self join should work wonders. > > I didn't test this, but the idea should work: > > > select t1.app_id as a1, t2.app_id as a2, t2.word, t2.score > from tablename as t1 > left join tablename as t2 > on t1.resource_id = t2.resource_id and t1.ap

Re: [PHP-DB] Join on single table

2005-02-11 Thread Micah Stevens
Sounds like a self join should work wonders. I didn't test this, but the idea should work: select t1.app_id as a1, t2.app_id as a2, t2.word, t2.score from tablename as t1 left join tablename as t2 on t1.resource_id = t2.resource_id and t1.app_id != t2.app_id group by word order by word voila

Re: [PHP-DB] Join on single table

2005-02-11 Thread Matthew Weier O'Phinney
* Martin Norland <[EMAIL PROTECTED]>: > Matthew Weier O'Phinney wrote: > > I have a table which contains the following: > > id (primary key, auto incrementing) > > app_id (integer, foreign key) > > resource_id (integer, foreign key) > > word > > score > > > > (This is a search

Re: [PHP-DB] Join on single table

2005-02-11 Thread Martin Norland
Matthew Weier O'Phinney wrote: I have a table which contains the following: id (primary key, auto incrementing) app_id (integer, foreign key) resource_id (integer, foreign key) word score (This is a search index.) I want to find all resource_ids from one app_id that match resour