日期:2014-05-19  浏览次数:20370 次

选择语句,谢谢!!
create   table   Teacher(No   char(3),Name   char(12),sex   char(2),birthday   datetime,Prof   char(6),Depart   char(20));


insert   into     teacher   (no,name,sex,birthday,prof,depart)
  values     ( '804 ', '李诚   ',   '男 ', '58/12/02 ', '副教授     ', '计算机系   ');
insert   into     teacher   (no,name,sex,birthday,prof,depart)
  values     ( '856 ', '   张旭     ',   '男 ', '69/03/12 ', '讲师   ', '电子工程系   ');

insert   into     teacher   (no,name,sex,birthday,prof,depart)
  values     ( '825 ', '   王萍     ',   '女 ', '72/05/05 ', '助教   ', '计算机系   ');

insert   into     teacher   (no,name,sex,birthday,prof,depart)
  values     ( '831 ', '   刘冰     ',   '女 ', '77/08/15 ', '助教     ', '电子工程系   ');
insert   into     teacher   (no,name,sex,birthday,prof,depart)
  values     ( '804 ', '李j   ',   '男 ', '58/12/02 ', '教授     ', '算机系   ');

--列出所有没有讲课的教师的name和depart
请问怎么写啊?

------解决方案--------------------
讲课?课呢?
------解决方案--------------------
create table Teacher(No nvarchar(3),Name nvarchar(12),sex nvarchar(2),birthday datetime,Prof nvarchar(6),Depart nvarchar(20));


insert into Teacher (no,name,sex,birthday,prof,depart)
values ( '804 ', '李诚 ', '男 ', '1958/12/02 ', '副教授 ', '计算机系 ');
insert into teacher (no,name,sex,birthday,prof,depart)
values ( '856 ', ' 张旭 ', '男 ', '1969/03/12 ', '讲师 ', '电子工程系 ');

insert into teacher (no,name,sex,birthday,prof,depart)
values ( '825 ', ' 王萍 ', '女 ', '1972/05/05 ', '助教 ', '计算机系 ');

insert into teacher (no,name,sex,birthday,prof,depart)
values ( '831 ', ' 刘冰 ', '女 ', '1977/08/15 ', '助教 ', '电子工程系 ');
insert into teacher (no,name,sex,birthday,prof,depart)
values ( '804 ', '李j ', '男 ', '1958/12/02 ', '教授 ', '算机系 ');

create table course1(cno nvarchar(10),cname nvarchar(10),tno nvarchar(10))
insert
into course1(cno,cname,tno)
values( '3-105 ', '计算机导论 ', '825 ')
insert
into course1(cno,cname,tno)
values( '3-245 ', '操作系统 ', '804 ')
insert
into course1(cno,cname,tno)
values( '6-166 ', '数据字电路 ', '856 ')
insert
into course1(cno,cname,tno)
values( '9-888 ', '高等数据学 ', '100 ')
insert
into course1(cno,cname,tno)
values( '6-187 ', '数据库系统 ', '804 ')

select * from Teacher as tmp
where not exists(select 1 from course1 where tno=tmp.No)