I would have created a table with the student info, then using an id field
from the student table, created a table that had student id, question #, and
answer.  Obviously there would also be a table that had question number and
question.  So to pull the info, I would do the following select:


Tables:
Student_table
Student_id
Student_name
....

Question_table
Question_id
Question

Student_question_table
Student_id
Question_id
Answer


Select student_name,  question, answer
>From student_table a , question_table b , student_question_table c
Where a.student_id=c.student_id and b.question_id=c.question_id

Eric

-----Original Message-----
From: Robert Everland III [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 07 March 2006 06:56
To: CF-Talk
Subject: Query brain teaser

I have come across this a few times and was wondering how some of you would
attack it.

I have a table that looks like this


uniqueID   q1 q2 q3 ... q50

In reality the table should look like this

uniqueID   studentID  answer   qid


I need it to have multiple records so I can do a join on a table that holds
the answer which is written as a table with multiple records as opposed to a
table with multiple columns.I know I can accomplish this in coldfusion. The
way I did it was to query the big table, then create a structure so each
column was in a structure. What would you have done?



Bob



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234579
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to