Re: Complicated query
Date: Sun, 7 Dec 2014 12:05:18 -0500
Message-ID: <1vfpx8req13ag.a3n36ahpsxl3.dlg_at_40tude.net>
On Sat, 06 Dec 2014 08:28:18 -0500, Shelly wrote:
> I have finally come across a desired query that I have no idea on how to
I know this will piss off normalized Jerry Stuckle, but I'd just as soon
use one table.
> do -- or if it is even possible. Here is the scenario:
>
> Table Instances
> ===============
> id
> column1
> column2
> (and more)
>
> Table Questions
> ===============
> Id
> Question Text
>
> Table Answers
> =============
> Id
> QuestionId (Id in Questions)
> InstanceId (Id in Instances)
>
> Table Questions has Q entries. (Lets say just three for now.) What I
> want is to pull where each record contains:
>
> Table Instances has N entries.
>
> Table Answers has Q x N entries.
>
> I want to pull N records where each record has:
> column1, column2, Answer1, Answer2, Answer3
>
> In other words, I want all the answers (Q of them) for a given instance
> to be in a single returned record, not one answer in each of Q records
> returned.
Columns would be
Question
Achoice
Bchoice
Cchoice
Dchoice
Correct