首页 > 数据库技术 > 详细

数据库---高级查询

时间:2016-01-18 16:08:17      阅读:137      评论:0      收藏:0      [点我收藏+]

高级查询:
    一:多表连接
    1.select Info.Code,Info.Name,Nation.Name from Info,Nation where Info.Nation = Nation.Code
    select * from Info,Nation

    2.join连接
    select * from Info join Nation on Info.Nation = Nation.Code
    
    二:多表联合
    select * from Info where Code=‘p001‘union select * from Info where Nation=‘n001‘

    三:子查询(无关子查询)
    select * from Info where Nation = (select Code from Nation where Name=‘汉族‘)
    select * from Info where Nation in (select Code from Nation where Name=‘汉族‘ or Name=‘苗族‘)

    四:子查询(相关子查询)
    select * from Car a  where a.Oil <(select avg(Oil) from Car b where b.Brand = a.Brand)


    
   

数据库---高级查询

原文:http://www.cnblogs.com/0927wyj/p/5139528.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!