Re: Big SELECT: ordering results by where matches are found

2007-09-11 Thread Chris Sansom
At 13:34 -0400 10/9/07, Baron Schwartz wrote: Looks like you've found the solution you need. The only other suggestion I have is to use UNION ALL if you don't need to eliminate duplicate rows in the UNION, because there's some overhead for checking for them. Hi Baron Thanks for this, and I

Big SELECT: ordering results by where matches are found

2007-09-10 Thread Chris Sansom
I'm sure there must be an accepted technique for this, but it's something I haven't tried before, so if anyone can point me in the right direction I'd be grateful. I'm writing a search facility for a site where the data is stored in several tables - let's say 5 for this example - and I want

Re: Big SELECT: ordering results by where matches are found

2007-09-10 Thread Baron Schwartz
Chris Sansom wrote: I'm sure there must be an accepted technique for this, but it's something I haven't tried before, so if anyone can point me in the right direction I'd be grateful. I'm writing a search facility for a site where the data is stored in several tables - let's say 5 for this

Re: Big SELECT: ordering results by where matches are found

2007-09-10 Thread Chris Sansom
At 11:01 -0400 10/9/07, Baron Schwartz wrote: I've built similar systems with a series of UNION queries. Each UNION has a column for relevance, which can be a sum of CASE statements, such as IF(name matches, 1, 0) + IF(text matches, 1, 0) AS relevance... The entire UNION can then be ordered by

Re: Big SELECT: ordering results by where matches are found

2007-09-10 Thread Chris Sansom
At 11:01 -0400 10/9/07, Baron Schwartz wrote: The entire UNION can then be ordered by relevance. You could also just add in an arbitrary number in each UNION, to get the effect of ordering by where in the hierarchy the match is found. Actually, your pointing me towards UNION may have done

Re: Big SELECT: ordering results by where matches are found

2007-09-10 Thread Baron Schwartz
Chris Sansom wrote: At 11:01 -0400 10/9/07, Baron Schwartz wrote: The entire UNION can then be ordered by relevance. You could also just add in an arbitrary number in each UNION, to get the effect of ordering by where in the hierarchy the match is found. Actually, your pointing me towards