有学生表student(stu_id,stu_name),借阅表book(stu_id,b_name),查询从来借过一本书的学生列表。就是这个......

解决方案 »

  1.   

    select * from student where stuid in 
    (select stu_id from book where b_name = 'yourbookname')
      

  2.   

    --从来未借过一本书?select
      *
    from 
      student
    where
      not exists(select 1 from book where stu_id=studenet.stu_id)
      

  3.   

    是从来没借过打的吧!
    select * from student
    where not exist (select distinct stu_id where student.stu_id = book.stu_id)
      

  4.   

    SELECT * FROM student WHERE stuid IN
    (SELECT stuid  FROM book GROUP BY stuid  HAVING COUNT(b_name)=1)
      

  5.   


    select *from  student where stu_id in (select stu_id from book  group by stu_id having count(b_name)=1)
      

  6.   

    select * from student where stu_id not in(select distinct stu_id from book)