By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,411 Members | 1,287 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,411 IT Pros & Developers. It's quick & easy.

left outer join/inner join statement

P: 46
Here I have a code for a view that has been created by a developer on my team. I am trying to use the very same code to create a view for a different formid/quesid. But I cannot figure out how this one starts and ends. can someone please help.
here's the code from the developer.
Expand|Select|Wrap|Line Numbers
  1. SELECT     a.EvalRecNo, w1.q1, w2.q2, w3.q3, w4.q4, w5.q5, w6.comment
  2. FROM         (SELECT DISTINCT u.EvalRecNo
  3.                        FROM          dbo.UData AS u INNER JOIN
  4.                                               dbo.EvalIssue AS e ON u.EvalRecNo = e.RecNo
  5.                        WHERE      (e.FormNo = 'R507') AND (e.DateComplete IS NOT NULL)) AS a LEFT OUTER JOIN
  6.                           (SELECT     u.EvalRecNo, u.NumAns AS q1
  7.                             FROM          dbo.UData AS u INNER JOIN
  8.                                                    dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
  9.                             WHERE      (fq.QuesID = 858)) AS w1 ON a.EvalRecNo = w1.EvalRecNo LEFT OUTER JOIN
  10.                           (SELECT     u.EvalRecNo, u.NumAns AS q2
  11.                             FROM          dbo.UData AS u INNER JOIN
  12.                                                    dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
  13.                             WHERE      (fq.QuesID = 859)) AS w2 ON a.EvalRecNo = w2.EvalRecNo LEFT OUTER JOIN
  14.                           (SELECT     u.EvalRecNo, u.NumAns AS q3
  15.                             FROM          dbo.UData AS u INNER JOIN
  16.                                                    dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
  17.                             WHERE      (fq.QuesID = 860)) AS w3 ON a.EvalRecNo = w3.EvalRecNo LEFT OUTER JOIN
  18.                           (SELECT     u.EvalRecNo, u.NumAns AS q4
  19.                             FROM          dbo.UData AS u INNER JOIN
  20.                                                    dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
  21.                             WHERE      (fq.QuesID = 861)) AS w4 ON a.EvalRecNo = w4.EvalRecNo LEFT OUTER JOIN
  22.                           (SELECT     u.EvalRecNo, u.NumAns AS q5
  23.                             FROM          dbo.UData AS u INNER JOIN
  24.                                                    dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
  25.                             WHERE      (fq.QuesID = 862)) AS w5 ON a.EvalRecNo = w5.EvalRecNo LEFT OUTER JOIN
  26.                           (SELECT     u.EvalRecNo, u.TxtAns AS comment
  27.                             FROM          dbo.UData AS u INNER JOIN
  28.                                                    dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
  29.                             WHERE      (fq.QuesID = 865)) AS w6 ON a.EvalRecNo = w6.EvalRecNo

I'd like to do the exact same thing with this code:
Expand|Select|Wrap|Line Numbers
  1. select b.quesid, b.formno, b.questext, d.numans, d.txtans from uquestionbank b, uformquestion f, udata d
  2. where b.quesid = f.quesid
  3. and f.quesformid = d.quesformid
  4. and b.formno = 'R102'
  5. and f.quesid in (486,519,522)
Can someone please tell me how the first query works because everytime I try to interpret it and make my own - i end up in circles.

Thank you,
Dec 11 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 8,127
The first query is a inline view and the view is based on a number of joins.

Refer the person who has developed it because i don't have any idea of your table structure.
Dec 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.