472,127 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

left outer join/inner join statement

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
  30.  
******************************

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
1 4474
debasisdas
8,127 Expert 4TB
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.

Similar topics

1 post views Thread by Justin Hennessy | last post: by
3 posts views Thread by rrstudio2 | last post: by
4 posts views Thread by polycom | last post: by
9 posts views Thread by shapper | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.