需要使用WHERE编写查询的帮助

时间:2019-05-25 01:48:11

标签: sql oracle

写一个查询以显示所有男性职员的职员编号,职员全名,专业编号。

[unowoned self]
  

SQL>描述人员

SELECT staffid, firstname, lastname, specid, specname 
  FROM staff, staffspeciality, speciality     
 WHERE speciality.specid = staff_speciality.specid     
 WHERE staff.staffid = staff_speciality.staffid     
 WHERE gender = ‘M’;
  

SQL>描述专业;

Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 STAFFID                                   NOT NULL CHAR(2)
 FIRSTNAME                                          VARCHAR2(20)
 LASTNAME                                           VARCHAR2(20)
 ROLE                                               VARCHAR2(15)
 GENDER                                             CHAR(1)
 DATEJOINED                                         DATE
 DATELEFT                                           DATE
  

SQL>描述staff_speciality;

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 SPECIALID                                 NOT NULL CHAR(4)
 SPECNAME                                           VARCHAR2(20)
 SPECNOTES                                          VARCHAR2(100)

1 个答案:

答案 0 :(得分:0)

赞:

SELECT staff.staffid, staff.firstname, staff.lastname, staff_speciality.specid, speciality.specname 
  FROM staff 
  JOIN staff_speciality
    ON staff.staffid = staff_speciality.staffid   
  JOIN speciality     
    ON speciality.specid = staff_speciality.specid         
 WHERE gender = ‘M’;