基础语句
select * from tb1;
select * from tb1 limit 3;
select name,age from tb1; select name,age from tb1 where age = 25;
select * from tb1 where age != 28;
select * from tb1 where age >= 25 and age <=28;
select name,age from tb1 where age between 25 and 28;
select * from tb1 where age = 25 or age = 28;
select * from tb1 where age not between 25 and 28;
select * from tb1 where age < 25 or age > 28; select * from tb1 where name like 'j%';
select * from tb1 where name like 't__';
select * from tb1 where name rlike '^t.*'; select * from tb1 where age in (22,23,24,25);
select * from tb1 where age not in (28,33,43); select * from tb1 order by age;
select * from tb1 order by age asc;
select * from tb1 order by age desc;
select * from tb1 order by age desc,name asc; select distinct age from students; #去重查询
select name as StuName,age from tb1;
分组与聚合
select gender,sum(age) from students group by gender;
select classid,avg(age) as avgage from students group by classid having avgage > 25;
select sum(age) from students where age > 19 group by gender;
多表查询
# 交叉连接
select * from t1 cross join t2 cross join t3;
select * from t1,t2,t3;
# 内连接
select * from t1 inner join t2 on t1.t1id=t2.t2id;
select * from t1,t2 where t1.t1id=t2.t2id;
# 外连接
select * from t1 right outer join t2 on t1id=t2id;
select * from t1 left outer join t2 on t1id=t2id;
select * from t1 right join t2 on t1id=t2id;
select * from t1 left join t2 on t1id=t2id;
#联合查询
select * from t1 union select * from t2; #重复数据合并
select * from t2 union all select * from t4; #显示重复记录
#全连接
>

9、select 语句的更多相关文章

  1. oracle(sql)基础篇系列(一)——基础select语句、常用sql函数、组函数、分组函数

        花点时间整理下sql基础,温故而知新.文章的demo来自oracle自带的dept,emp,salgrade三张表.解锁scott用户,使用scott用户登录就可以看到自带的表. #使用ora ...

  2. CREATE TABLE 表名 AS SELECT 语句

    1.新表不存在复制表结构即数据到新表 ? 1 2 create table new_table select * from old_talbe; 这种方法会将old_table中所有的内容都拷贝过来, ...

  3. 优化Select 语句的原则

    优化Select 语句的原则 -摘抄<SQL Server 2005 性能监测与优化> Select 语句是数据库应用系统中最常用的语句之一,Select 语句设计的好坏直接影响到应用程序 ...

  4. SQL指南-SELECT语句

    SELECT 语句 SELECT 语句用于从表中筛选数据.列表结果存储于一个结果表中(称作result-set) 语法 SELECT column_name(s)FROM table_name 注意: ...

  5. SQL Server(三):Select语句

      1.最基本的Select语句: Select [Top n [With Ties]] <*|Column_Name [As <Alias>][, ...n]> From & ...

  6. SQL SELECT 语句

      本章讲解 SELECT 和 SELECT * 语句. SQL SELECT 语句 SELECT 语句用于从表中选取数据. 结果被存储在一个结果表中(称为结果集). SQL SELECT 语法 SE ...

  7. Select语句也会引起死锁

    项目上线,准备验收前出现了一个严重的问题:很多select语句作为死锁的牺牲,大部分报表无法打开.这个问题影响范围很大所有的报表都无法访问,而我们的报表是放在电视上面轮播的,电视放在工厂里面,所以出现 ...

  8. 一条Select语句丛生到死的处理过程

    以一条普通的“select * from table order by …”语句为例.图2-21中显示为该语句在数据库中各个组件之间的处理过程,各个步骤分别代表: (1)select语句通过网络传送给 ...

  9. select语句for update---转载

    作用: Select…For Update语句的语法与select语句相同,只是在select语句的后面加FOR UPDATE [NOWAIT]子句. 该语句用来锁定特定的行(如果有where子句,就 ...

  10. 如何阻止SELECT * 语句

    我们每个人都知道是个不好的做法,但有时我们还是要这样做:我们执行SELECT * 语句.这个方法有很多弊端: 你从你的表里返回每个列,甚至后期加的列.想下如果你的查询里将来加上了VARCHAR(MAX ...

随机推荐

  1. SUSE Linux 多路径软件+LVM+裸设备的配置

    1.先要查出光纤卡的WWN号,SUSE 10下光纤卡的WWD在/sys/class/fc_host/host5/port_name文件中,有两块卡就会有两个host*的目录 接好光纤后可以在dev下可 ...

  2. Mockplus设计大赛获奖选手专访 | Intimate:你的专属密友音乐播放器

    “Intimate中文意思是密友,就是想让这个音乐APP成为最懂用户的一款软件.” 如果,你随身听的音乐APP,可以成为知你懂你的密友,你幸福,她清唱一首<小幸运>:你悲伤,她低声浅吟&l ...

  3. 以二进制的形式查看文件 Linux之od命令详解

    od命令 以二进制的形式查看文件 od -t x1 /usr/local/FT/config/hsm_create.utf8.sql ef bb bf 4c 5f 0d 0a 5f 4e 4e 4f ...

  4. spring加载ApplicationContext.xml的四种方式

    spring 中加载xml配置文件的方式,好像有4种, xml是最常见的spring 应用系统配置源.Spring中的几种容器都支持使用xml装配bean,包括: XmlBeanFactory , C ...

  5. 实践作业4:Web测试实践(小组作业)每日任务记录2

    实践作业4:Web测试实践(小组作业)每日任务记录2 会议时间:2017年12月22日 会议地点:东九教学楼自习区 主  持  人:王晨懿 参会人员:王晨懿.余晨晨.郑锦波.杨潇.侯欢.汪元 记  录 ...

  6. python 中面向对象编程简单总结3--定制类

    声明:资源来自慕课网python学习课程,以下只是个人学习总结,仅供参考 1.Python类的特殊方法 特征:以  __ 开头并结尾的方法,比如用于print的__str__() , __getatt ...

  7. PHP Windows系统下调用OpenOffice

    项目需要把用户上传的word文档转换为pdf文件,方便用户浏览.经过谷歌百度找到PHP可以使用COM组件调用微软的openoffice来实现文档转换 1,安装OpenOffice 安装OpenOffi ...

  8. [GO]channel实现同步

    goroutine运行在相同的地址空间,因此访问共享内存必须 做好同步.goroutine奉行通过通信来共享内存,而不是共享内存通信 它跟map一样,使用make来创建,它是一个引用 ,而不是值传递 ...

  9. CodeForces 682A Alyona and Numbers (水题,数学)

    题意:给定两个数 m,n,问你在从1到 n,和从 1到 m中任选两个数加起来是5的倍数,问你有多少个. 析:先计算 m 和 n中有多少个取模5是从0到4的,然后根据排列组合,相乘就得到了小于等于 m ...

  10. windows10最实用的快捷键、高效的windows模式

    win+方向键 将软件窗口放置到方向 ctrl+win+左右方向键 切换虚拟桌面 win+tab 选择窗口或虚拟桌面,然后按着win随后放开,界面停留 alt+tab 切换窗口 ctrl+win+D ...