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
 Transact-SQL (2000)
 Query based on columns AND CSV based columns

Author  Topic 

computerforce
Starting Member

10 Posts

Posted - 2007-02-05 : 15:49:01
I'll try to simplify the problem as much as I can.

There's survey. It has different types of question answer pairs, but the problem is in Multiple Choices, Multiple Answers questions, where user can choose, for example 3 checkboxes from 5 at the web form, for the question.

I am emphasizing three tables:

tbl_questions
IDquestion (primary)
question (textual question)

tbl_answers
IDanswer (primary)
IDquestion (foreign,to table tbl_questions)
answer (textual answer)

tbl_results
IDresult (primary)
IDquestion (foreign, to tbl_question)
result (string based on CSV, may contain few IDanswers, because visitor may choose few checkboxes, for example it can be "4,6,7")

Inside those tables are data (I'll put here just two questions):

Example:
tbl_questions
IDquestion_question
1_________Which OS do you use?
2_________Which databases do you use?

tbl_answers
IDanswer_IDquestion_answer
1________1_________Windows
2________1_________Linux
3________1_________Mac OS
4________2_________SQL Server
5________2_________MS Access
6________2_________MySQL
7________2_________Oracle
8________2_________Other
9________2_________No, I do not use databases

tbl_results
IDresult_IDquestion_results
........
23_______1________1,2
24_______2________4,6,7
........

Is there a possibility to make query, using columns, but also the data inside the CSV format in results (varchar or char) column?

Result of the query would be:
IDquestion_IDanswer_answer
1_________1________Windows
1_________1________Linux
2_________4________SQL Server
2_________6________MySQL
2_________7________Oracle

Further queries based on this query should be able to make statistics (GROUP BY).
   

- Advertisement -