SQL how to query on self-join -


A SQL question has confused me very much, I have two tables like this

 < Code> Table Create Faculty (FAC Focus First Name FAC Last Name Not FIC Supervisor)   

Second

  Table offer (offer a Course of Offer Offline Application No))   

Now I have to write a question which is listed for the names of the faculty members and the curriculum number, Faculty teaches members the same course of his supervisor in 2010.

I try to write a question like this

  selected fa.facno, fa.facfirstname, as fa.faclastname fa, as faculty fs , Offering as an o, offering as a fa where fa.FacSupervisor = fs.FacNo and fa.FacNo = o.FacNo and fa.FacSupervisor = os.FacNo and o.OffYear = 2010   

But I am not the right answer, so please give me some pointers

Thanks to every one, I worked as the bottom

  FacFirstName, F.FacLastName, s.FacFirstNa as Superstorm, SFA Superlansnam as the first name, o Not as a faculty as faculty, as a faculty, presenting as an o, offering as an OS where f.FacSupervisor = os.FacNo and f.FacNo = o.FacNo and o.CourseNo = o.co.no And F. FCS Supervisor = s.FacNo and o.OffYear = 2010 and os.OffYear = 2010   

I hope this is useful for some new SQL leaner that faces the same problem < / P>

"therefore please give me some signals"

Since this is you question, I I am happy to provide a hint.

Make your joints clear - it is very helpful in readability, for example: F. S. ON FA as faculty in the form of FA Inner Joy Faculty. FACS Exporter = FSFCAC Inner Join of O.F. FACNO = O. FACCN Inner joining of OS on OS FS .FacNo = os.FacNo

Once you do this, I suspect that you will have better luck in seeing any problems or if someone And will be easy to help.

Then you have to filter with

  WHERE O. [No course] = OS [Course no] and o OFFICE = 2010    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -