Advertisement

08.29.2008 at 02:50AM PDT, ID: 23688308
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Sql query Join problem

Asked by copyPasteGhost in SQL Query Syntax

Tags:

Hello I'm looking for the most efficient way to perform this query. I have a list of categories. (table name=Categories)  each category has a categoryname. this is linked to my businesses table(table name=Businesses) by a thrid table called "Category_Business".

In my Categories table I have a field called EnglishID Which contains the unique id (of type int) of the category name. And a field called LanguageID (of type char(3)) to specify which language to return. (language ID and englishID make up a unique field). There are currently 10,000 records in this table and it is expected to grow to over one million.

In my Businesses Table I have a field called txtBusinessID which is a unique identifier for the business. (of type char(7))

Category_Business looks like this.

EngID                      int      Unchecked
BusinessID      char(7)      Unchecked

Here is what I want to do.

I would like to be able to write a stored proc to return me a recordset of buiness Information given a search string.

Ex. Let's I have the catgories Auto, Automotive-Repair, Automotive-Sales, Automotive Parts, Beauty (each with their respecitive Engish Id's)

I want to create a point like system for search results.
If whole word match award 5 points,
If match contains word - 4 points
If match contains 75% of Search string - 3 points
If match contains 50% of search string - 2 points
If match contains 25% of search string - 1 points

If match contains less than 25% of search string - 0 points (Don't return)

When I search for Auto I want to get returned :
Auto (5 points)
Automotive-Repair (4 points),
Automotive-Sales (4 points),
Automotive Parts (4 points),
Beauty (0 points)

Then I can get the result back order by points  (search relevence). Then I can also order it by distance (which is another question which I will ask after this one).

Right now I have a wrote a stored proc to return everything for a given business. which is useless since no one knows the unique identifier but me. ( I did it more for layout testing). But now the time has come to have a real search.  This is what I have so far....


Might be of use...
You will notice at the end I try to do an order by distance. It doesn't work. I'm not familiar with inner, outer, left outer joins. but I've been told they make queries faster, so any pointers would be great.

Thanks in advance
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
ALTER PROCEDURE [dbo].[usp_ReturnSearchResults]
	-- Add the parameters for the stored procedure here
	@SearchText		nvarchar(max),
	@Username		nvarchar(50),
	@LangID			char(3),
	@UserPostalCode	char(7)
 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
 
	DECLARE @userLat decimal(16,12);
	DECLARE @userLong decimal(16,12);
 
	SELECT @userLat=LATITUDE, @userLong=LONGITUDE 
	FROM postalCodes 
	WHERE POSTAL_CODE = @UserPostalCode
 
	Select txtBusinessID, txtBusinessName, imageLogo, txtCity, Bus_Lang_Desc.ShortDes as [ShortDesc], dbo.DistanceAssistant(@userLat,@userLong,LATITUDE,LONGITUDE) AS [distance]
	FROM dbo.businesses, dbo.Bus_Lang_Desc, dbo.PostalCodes 
	WHERE Bus_Lang_Desc.LanguageID = @LangID 
		AND businesses.txtBusinessID = Bus_Lang_Desc.BusID
		AND businesses.txtBusinessID = @SearchText
		AND businesses.txtPostalCode = PostalCodes.POSTAL_CODE
	ORDER BY [distance]
END
[+][-]08.29.2008 at 04:14AM PDT, ID: 22344186

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.29.2008 at 04:19AM PDT, ID: 22344212

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.29.2008 at 04:23AM PDT, ID: 22344234

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.29.2008 at 04:27AM PDT, ID: 22344255

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Query Syntax
Tags: SQL Syntax
Sign Up Now!
Solution Provided By: copyPasteGhost
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906