Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Union SQL order of results for search engine

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-27 : 08:39:11
Bud writes "I am performing queries against the same table multiple times with different conditions. Each query is done in the order of its relevance of a group of search words.

I was using multiple calls from a webservice to fill a datatable in a .net dataset and that kept them grouped but was hard to keep duplicate records from showing up.

So i thought the UNION might work but that keeps me from ordering each query individually and then keeping the groups in order.

The less times I have to send a query from the websevice the more efficiant it should be, I just can't seem to nail down how to build a query that brings in groups of records with their own order and keep the groups in the order I want them and keep duplicate records from occuring and drop it all into a datatable in a dataset.

Although I assume this is a common need in search engines I have not had luck with a solution.

Thanks

Bud"

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-27 : 09:16:27
SELECT * FROM ((SELECT * FROM table ORDER BY x) AS XXX UNION (SELECT * FROM table ORDER BY y) AS YYY) AS ZZZ


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -