

SQL学习--单表查询
source link: https://fann.im/blog/2008/04/14/sql-study-select-1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

SQL学习--单表查询
Apr 14, 2008
指定列:select Sno,Sname from Student;
查询经过计算的值:select Sname, 'year of birth:', 2008-Sage, Sdept from student;
去除取值重复的行:select distinct Sno from student;
足条件的元组:select Sname,Sage from Student where Sdept ='CS' AND Sage<=19;
确定范围,集合 select Sname from Student where Sage BETWEEN 18 AND 20;
匹配查询 select * from Student where Sno LIKE '100%';
Order By子句 select Sno,Grade from SC where Cno ='2' ORDER BY Grade DESC;
//DESC是降序,缺省为升序
聚集函数:select COUNT(Sno) from Student;
Group By子句:select Cno,COUNT(Cno) from SC GROUP BY Cno;
Was this page helpful?
Recommend
-
47
单表简单查询 前几天记了下创建、删除、修改数据库,表啊之类的学习笔记,今天终于要开始查询了,查询数据嘛~在我心里反正挺难的,毕竟SQL不好写,脑袋笨啊。 首先呢,Mysql官方提供了一个数据库实例给我们用,那~就是大名...
-
57
程序员 - @qianji201712 - 想向大家请教一个问题:个人项目,之前用阿里云服务器,不过数据库是自建的 MySQL,一直是单服务器单表存储,备份是每天 dump 一次然后备份到云盘。目前用户注册量上来后,每天差不多
-
61
今天,探讨一个有趣的话题: MySQL 单表数据达到多少时才需要考虑分库分表? 有人说 2000 万行,也有人说 500 万行。 那么,你觉得这个数值多少才合适呢?
-
50
MySQL单表数据不要超过500万行:是经验数值,还是黄金铁律? 发表于
-
34
数据库 - @FONG2 - 以前设计是以请求编号为主键的,现在优化后以用户编号为主键,那么就存在大量重复数据了。现在用 sql 查一下都得等半天,请问有啥好方法处理么
-
8
没有几个单表查询的情况下,有必要使用mybaties plus吗魔力猫 26分钟前 ...
-
6
mysql性能优化:单表1400w查询最后十条数据(耗时0.036s)
-
6
互联网大厂都是单表查询的吗?表设计都尽量没有外键的吗?
-
3
单表根据时间段查询百万数据如何优化 ...
-
2
SQL如今流行单表设计 23-01-09 banq...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK