表的连接: 外链接: ——左连接:left [outer] join ——右连接:right [outer] join ——全连接:full [outer] join 同样也可以使用'+'来表示,只适用于左右连接,有‘+’的一方是连接方 内连接: 在数据库操作中,不同表之间可以通过相同类型的列,进行关联查询, 例子: select*from book left outer outer join borrow on book.bid=borrow.bid; select bname,sname from book,borrow,student where borrow.bid=book.bid and borrow.sid=student.sid and book.bname =|in 'java';当只有一本叫java的书的时候用=,有多本时用in 题目: 1、根据书的id查询借书人的名字 2、根据书的id查询借书人的年龄 3、根据借书人的id查询借的书籍 题1思路: 1.bid=1, 2.borrow查bid=1的人的sid; 3.从student表中查询sid对应的sname select sname ,sage from student where sid=( select sid from borrow where bid =1 ) 题目3: select bname from book where bid=( select bid from borrow where sid=( select sid from student where sid=1001 ) ); |
|
来自: weixiaofeng01 > 《oracle》