vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have 3 table A, B, C. I have shown sample data in the tables below: Table A: Tabel A: This table represents the fields in a form. Each field can have 1 or more options. So in this case field 1 has 2 options – 1 & 2. Where as field 5 has no options – ie it may be a text field. FldId Field Option 1 1 1 2 1 2 3 2 3 4 2 4 5 3 Table B: represents respondents. RespId Name 100 A 101 B 102 C Table C represents the data submitted by respondents Resp Fld Opt Value 100 1 2 100 2 3 100 2 4 100 3 DK 101 1 1 101 2 3 101 3 SK 102 3 ME This means respondent A (with respId 100) answered field 1 and selected option 2. He also asnwered field 2 and selected both options 3 & 4. and so on... Now I want to output the respondent data in the foll. matrix format: 1 2 3 4 5 100 1 1 1 DK 101 1 1 SK 102 ME Where row 1 represents the FldId from table A. Column represents each respondent. and the intersection of a column and row represents if a respondent selected an option. If respondent selected an option it is represented by a "1". If not, then the cell is blank. If the field is a text field (as in FldId 5), the actual value is put in cell. Currently I am looping through result sets to display the data (loop within loop) - is there a way to do this in one query. Thanks for any help. DK |