在sql中使用not in clause正确的方法,不知道如何从性别中选择

时间:2021-09-17 04:04:31
EMPLOYEE (fmane, minit, lname, ssn, birthdate, address, sex, salary, superssn, dno) KEY: ssn
DEPARTMENT (dname, dnumber, mgrssn, mgrstartdate) KEY: dnumber.
PROJECT  (pname, pnumber, plocation, dnum) KEY: pnumber.
WORKS_ON (essn, pno, hours) KEY: (essn, pno)
DEPENDENT  (essn, dependent-name, sex, bdate, relationship) KEY: (essn, dependent-name)

I want to get first and last names and ssn of each female employees with no dependents, but I get stuck at the final command part:

我想得到每个女性员工的姓名和ssn,没有家属,但我被困在最后的命令部分:

select e.lname, e.fname, e.ssn
from employee e
where e.ssn  not in (
select essn
from dependent
)

how do I add the gender part?

如何添加性别部分?

1 个解决方案

#1


0  

In SQL, you can combine multiple filters by using the AND keyword.

在SQL中,您可以使用AND关键字组合多个过滤器。

select 
   e.lname, e.fname, e.ssn
from employee e
where e.ssn  not in (
                      select essn
                        from dependent
                     )
    AND e.sex = 'Female'

#1


0  

In SQL, you can combine multiple filters by using the AND keyword.

在SQL中,您可以使用AND关键字组合多个过滤器。

select 
   e.lname, e.fname, e.ssn
from employee e
where e.ssn  not in (
                      select essn
                        from dependent
                     )
    AND e.sex = 'Female'