请诸位高手指教这道题的做法:
给出一个SQL:1999查询语句,打印既不是职员(employee)又不是客户(customer)的人员(person)的姓名(name)。
(
1. Table "person":
field: person_id (key), name, street, city
2. Table "employee":
field: salary
3. Table "customer"
field: credit_rating
"employee"和"customer"都是"person"的字表。
)
------解决方案--------------------
- SQL code
select a.namefrom perso aleft join employee b on a.person_id=b.person_idleft join customer c on a.person_id=c.person_idwhere b.person_id is null and c.person_id is null
------解决方案--------------------
select * from person where employee <> ... and customer <> ....
------解决方案--------------------
------解决方案--------------------
楼主说的"打印"是指前端程序的报表呈现吧?
把查询的结果集返回给前端程序,然后用报表工具显示出来即可.
------解决方案--------------------
此写法逻辑上等价于where xx not in(select ...)
但执行效率高于后者.