[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[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!

7.8

Sub select or charindex?

Asked by juliandormon in MS SQL Server

Tags: charindex, how, query

Ok I am not sure how to handle this query. Your help would be greatly appreciated.

I am trying to return a bunch of search results which are more or less strait forward, except that part of the results I am trying to get at could be multiple records in a related table. i'll try and explain:

I have a main table which stores info about a Photographer - this table relates to another which has a list of their specialties - so it looks like this :

Specialties Table
PhotographerID    SpecialtyID

1                           1
1                           2
1                           3
2                           1
2                           2

Now, here's the catch a person doing a search is allowed to search for more than one specialty - so I am trying to pass this to the SP as a comma deliminated string (1,2,3) So the search is looking for a Photographer who specializes in these 3 specialties. If it were just one then I could do a sub query - but how do you handle it in this case? I have used CharIndex in the past, but that was comparing a deliminated string against one value, where here there may be several.

Here's my attempt so far. But this only works if I pass one specialtyID and then I have to use Distinct as well

Alter PROCEDURE "sp_PagedItems_Listings"
        (
@Creator nvarchar(80) = null,
@DiciplineID int,
@SpecialtyID int, - this should probably be an nvarchar with the direction I am heading
@FacilityID int,
@Location nvarchar(500),
@Page int,
@RecsPerPage int
        )
AS

-- We don't want to return the # of rows inserted
-- into our temporary table, so turn NOCOUNT ON
SET NOCOUNT ON


--Create a temporary table
CREATE TABLE #TempItems
(
        ID int IDENTITY,
       ListingID int,
      ListingTypeID int,
       UserID int,
      FirstName nvarchar(50),
      LastName nvarchar(50)
)

INSERT INTO #TempItems (ListingID, ListingTypeID, UserID, FirstName, LastName)
Select Distinct Listings.ListingID, Listings.ListingTypeID, Listings.UserID, Users.FirstName, Users.LastName
From Listings
Inner Join Users On Users.UserID = Listings.UserID
Inner Join ListingSpecialtyDetails On ListingSpecialtyDetails.ListingID = Listings.ListingID
Where (ListingSpecialtyDetails.SpecialtyID IN (@SpecialtyID) OR @SpecialtyID is Null)
[+][-]09/25/03 10:37 AM, ID: 9430056Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 10:48 AM, ID: 9430157Author Comment

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/03 10:54 AM, ID: 9430202Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 11:00 AM, ID: 9430248Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 11:02 AM, ID: 9430265Author Comment

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/03 11:02 AM, ID: 9430266Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 11:04 AM, ID: 9430275Author Comment

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/03 11:06 AM, ID: 9430291Author Comment

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/03 11:15 AM, ID: 9430368Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 11:23 AM, ID: 9430418Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/25/03 11:29 AM, ID: 9430478Accepted Solution

View this solution now by starting your 30-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: MS SQL Server
Tags: charindex, how, query
Sign Up Now!
Solution Provided By: ScottPletcher
Participating Experts: 4
Solution Grade: A
 
[+][-]09/25/03 11:31 AM, ID: 9430486Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 11:33 AM, ID: 9430508Author Comment

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/03 11:39 AM, ID: 9430552Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 11:41 AM, ID: 9430568Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/03 12:02 PM, ID: 9430742Author Comment

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/03 01:53 PM, ID: 9431593Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81