首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SQL 1999 标准中“打印”语句的写法解决方法

2012-03-27 
SQL 1999 标准中“打印”语句的写法请诸位高手指教这道题的做法:给出一个SQL:1999查询语句,打印既不是职员(e

SQL 1999 标准中“打印”语句的写法
请诸位高手指教这道题的做法:
给出一个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 <> ....
[解决办法]
探讨
select * from person where employee <> ... and customer <> ....

[解决办法]
楼主说的"打印"是指前端程序的报表呈现吧?

把查询的结果集返回给前端程序,然后用报表工具显示出来即可.

[解决办法]
此写法逻辑上等价于where xx not in(select ...)
但执行效率高于后者.

热点排行