学生信息表:student
字段名称 数据类型 说明
stuID char(10) 学生编号,主键
stuName Varchar(10) 学生名称
major Varchar(50) 专业
图书表:book
字段名称 数据类型 说明
BID char(10) 图书编号,主键
title char(50) 书名
author char(20) 作者
借书信息表:borrow
字段名称 数据类型 说明
borrowID char(10) 借书编号,主键
stuID char(10) 学生编号,外键
BID char(10) 图书编号,外键
T_time datetime 借书日期
B_time datetime 还书日期
请编写SQL语句完成以下的功能:
1) 查询“计算机”专业学生在“2007-12-15”至“2008-1-8”时间段内借书的学生编号、学生名称、图书编号、图书名称、借出日期; 请问有多少种方式

解决方案 »

  1.   

    http://topic.csdn.net/u/20100517/17/b2ab9d5e-73a2-4f54-a7ec-40a5eabd8621.html?89116
    先看看这个
      

  2.   

    select a.学生编号,a.学生名称,b.图书编号c.图书名称,b.借出日期
    from student a inner join borrow b on a.stuid=b.stuid
    inner join book c on b.bid=c.bid
    where a.major='计算机' and b.t_time between '2007-12-15' and '2008-1-8'
      

  3.   

    select s.stuId,s.stuName,b.Bid,k.title ,b.T_time
    from student s
    inner join borrow b on s.stuid = b.stuid
    inner join book k on b.bid = k.bid
    where b.T_time between '2007-12-15'and '2008-1-8'
    and s.major = '计算机'
      

  4.   

    select
       a.stuID,a.stuName,b.bid,b.title,c.T_time 
    from
       student a,book b,borrow c
    where
       a.stuID=c.stuID
    and
       b.bid=c.bid
    and
       a.major='计算机' 
    and
       c.T_time  between '2007-12-15' and '2008-1-8'
       
      

  5.   

    看下sql基础把, 了解下between