数据库---高级查询
2016-01-18 15:54
309 查看
高级查询:
一:多表连接
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)
一:多表连接
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)
相关文章推荐
- oracle创建表空间,用户步骤
- 数据库---普通查询
- Sysbench0.5测试数据库性能
- 数据库---T-SQL语句提纲
- MongoDB 创建数据库、创建用户
- Linux下安装配置MongoDB数据库
- 初学数据库第一课
- Redis作为缓存自我总结
- Redis 3.0的集群部署
- csv 导 mysql
- Mysql中limit的用法详解
- 217,FMDB数据库操作
- Infinispan-Redis配置使用
- Windows下移动MariaDB数据目录 (转!)
- 初识MySQL数据库
- mysql判断表是否存在的语句
- SQL
- 数据库---MySQL练习题及答案
- oracle中trim,ltrim,rtrim函数用法
- 数据库 创建 查询 练习