But that would select survey results that user selects either "Caucasian" or "East Asian" and didn't select "Asian" so that wouldn't work for me. It's a multiple choice answer.
Main Topics
Browse All TopicsIs this possible to do in a query? The user can select multiple ethnic choices. In my query, I want to get all the survey results where user have selected "Asian" as the only or part of their answer. Currently, my query is not selecting survey results where user have selected "Asian" but also selected something else like Caucasian or Latino.
I put the "not like ....." code to make sure it doesn't select Caucasian or "East Asian" mistakenly as if user did select the "Asian" since the letters "asian" is part of the other 2 choices. What would be the best way to write this query to meet my needs? Thank you.
Also, i'm using MS Sql 2005
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
CREATE FUNCTION dbo.fn_ParseString(
@String varchar(8000) )
RETURNS @tbl TABLE ( s varchar(100) )
/*
SELECT * from dbo.fn_ParseString('Asian,
*/
AS
BEGIN
DECLARE @i INT, @j INT
SELECT @i = 1
WHILE @i <= DATALENGTH(@String)
BEGIN
SELECT @j = CHARINDEX(',', @String, @i)
IF @j = 0
BEGIN
SELECT @j = DATALENGTH(@String) + 1
END
INSERT @tbl SELECT SUBSTRING(@String, @i, @j - @i)
SELECT @i = @j + 1
END
RETURN
END
GO
create a function like this, form a Comma separated string for the User Choices like 'Asian,latino'
and modify ur query like this
and e.Value IN (SELECT * from dbo.fn_ParseString('Asian,
Instead of function, is there a way to put this in a query? To sumarize what I need in the query:
1. Select the survey results that has e.Value = "Asian" and they can also have selected e.Value = Caucasian or e.value="East Asian".
2. Do not select the survey results there is no e.value="Asian" but there are e.Value = Caucasian or e.value="East Asian".
Can this be expressed in a query? Thank you.
The reason I would like this in a query because I'm also embedding this query in a C# program
Business Accounts
Answer for Membership
by: aneeshattingalPosted on 2009-11-03 at 12:52:14ID: 25733466
where q.Text like '%Name of the project%'
and e.Value = 'Asian'