mysql语句查询练习



1、创建students表
mysql> create table students (
-> id int(10) auto_increment unique primary key,
-> name varchar(20) not null,
-> sex varchar(4),
-> age int(10),
-> class varchar(20) not null,
-> addr varchar(50)
-> );
创建scores表
mysql> create table scores(
-> id int(10) auto_increment primary key,
-> stu_id int(10) not null,
-> subject varchar(20),
-> grade int(10)
-> );
2、while循环批量造数据
delimiter $$;
create procedure best_test (count int)
begin
declare i int;
set i=0;
while i<count do
insert into students (name,sex,age)
values ('保总','男',21);
set i=i+1;
end while;
end
$$;
call best_test (500);
3、插入表一数据
INSERT INTO students(id, name, sex, age, class, addr)
VALUES ('801', '刘海洋', '男', '21', '乔巴', '北京市海淀区');
INSERT INTO students(name, sex, age, class, addr)
VALUES ('周飞', '男', '18', '乔巴', '北京市昌平区'),
('味全', '男', '26', '路飞', '湖南省永州市'),
('孙洋', '女', '21', '乔巴', '辽宁省阜新市'),
('李佳', '女', '22', '超人', '福建省厦门市'),
('保总', '女', '30', '乔巴', '湖南省衡阳市');
INSERT INTO students(id, name, sex, age, class, addr) VALUES('1001', '徐振永', '男', '21', '索隆', '辽宁省阜新市');
INSERT INTO students(name, sex, age, class, addr)
values(李卫强', '男', '18', '索隆', '福建省厦门市'),
('狄枫', '男', '26', '蜘蛛侠', '湖南省衡阳市'),
('女屌丝', '女', '21', '蜘蛛侠', '北京市海淀区'),
('郁燕', '女', '22', '索隆', '北京市昌平区'),
('裴颖菲', '女', '30', '索隆', '辽宁省阜新市'),
('1007', '戴小龙', '男', '50', '索隆', '福建省厦门市');
| id | name | sex | age | class | addr |
+------+-----------+------+------+-----------+--------------------+
| 801 | 刘海洋 | 男 | 21 | 乔巴 | 北京市海淀区 |
| 802 | 周飞 | 男 | 18 | 乔巴 | 北京市昌平区 |
| 803 | 味全 | 男 | 26 | 路飞 | 湖南省永州市 |
| 804 | 孙洋 | 女 | 21 | 乔巴 | 辽宁省阜新市 |
| 805 | 李佳 | 女 | 22 | 超人 | 福建省厦门市 |
| 806 | 保总 | 女 | 30 | 乔巴 | 湖南省衡阳市 |
| 1001 | 徐振永 | 男 | 21 | 索隆 | 辽宁省阜新市 |
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 |
| 1003 | 狄枫 | 男 | 26 | 蜘蛛侠 | 湖南省衡阳市 |
| 1004 | 女屌丝 | 女 | 21 | 蜘蛛侠 | 北京市海淀区 |
| 1005 | 郁燕 | 女 | 22 | 索隆 | 北京市昌平区 |
| 1006 | 裴颖菲 | 女 | 30 | 索隆 | 辽宁省阜新市 |
| 1007 | 戴小龙 | 男 | 50 | 索隆 | 福建省厦门市 |
+------+-----------+------+------+-----------+-------------------
插入表二数据
insert into scores (stu_id,subject,grade) values
-> (801,'计算机',98),
-> (801,'英语',80),
-> (802,'计算机',65),
-> (802,'中文',88),
-> (803,'中文',95),
-> (804,'计算机',70),
-> (804,'英语',92),
-> (805,'英语',94),
-> (806,'计算机',),
-> (806'英语'45),
-> (1001,'计算机',98)
-> (1002,'中文',88),
-> (1003,'中文',95),
-> (1002,'计算机'65),
-> (1004,'计算机',70),
-> (1004,'英语',70),
-> (1005,'英语',94),
-> (1006,'计算机',57),
-> (1006,'英语',45),
-> (1007,'英语',80)
-> ;
| id | stu_id | subject | grade |
+----+--------+-----------+-------+
| 1 | 801 | 英语 | 80 |
| 2 | 801 | 计算机 | 98 |
| 3 | 802 | 计算机 | 65 |
| 4 | 802 | 中文 | 88 |
| 5 | 803 | 中文 | 95 |
| 6 | 804 | 计算机 | 70 |
| 7 | 804 | 英语 | 92 |
| 8 | 805 | 英语 | 94 |
| 9 | 806 | 计算机 | 57 |
| 10 | 806 | 英语 | 45 |
| 11 | 1001 | 计算机 | 98 |
| 12 | 1002 | 中文 | 88 |
| 13 | 1003 | 中文 | 95 |
| 14 | 1002 | 计算机 | 65 |
| 15 | 1004 | 计算机 | 70 |
| 16 | 1004 | 英语 | 70 |
| 17 | 1005 | 英语 | 94 |
| 18 | 1006 | 计算机 | 57 |
| 19 | 1006 | 英语 | 45 |
| 20 | 1007 | 英语 | 80 |
4、查询表students所有内容
select * from students;
+------+-----------+------+------+-----------+--------------------+
| id | name | sex | age | class | addr |
+------+-----------+------+------+-----------+--------------------+
| 801 | 刘海洋 | 男 | 21 | 乔巴 | 北京市海淀区 |
| 802 | 周飞 | 男 | 18 | 乔巴 | 北京市昌平区 |
| 803 | 味全 | 男 | 26 | 路飞 | 湖南省永州市 |
| 804 | 孙洋 | 女 | 21 | 乔巴 | 辽宁省阜新市 |
| 805 | 李佳 | 女 | 22 | 超人 | 福建省厦门市 |
| 806 | 保总 | 女 | 30 | 乔巴 | 湖南省衡阳市 |
| 1001 | 徐振永 | 男 | 21 | 索隆 | 辽宁省阜新市 |
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 |
| 1003 | 狄枫 | 男 | 26 | 蜘蛛侠 | 湖南省衡阳市 |
| 1004 | 女屌丝 | 女 | 21 | 蜘蛛侠 | 北京市海淀区 |
| 1005 | 郁燕 | 女 | 22 | 索隆 | 北京市昌平区 |
| 1006 | 裴颖菲 | 女 | 30 | 索隆 | 辽宁省阜新市 |
| 1007 | 戴小龙 | 男 | 50 | 索隆 | 福建省厦门市 |
+------+-----------+------+------+-----------+--------------------
5、查询表students2~4条信息
select * from students limit 1,3;
+-----+--------+------+------+--------+--------------------+
| id | name | sex | age | class | addr |
+-----+--------+------+------+--------+--------------------+
| 802 | 周飞 | 男 | 18 | 乔巴 | 北京市昌平区 |
| 803 | 味全 | 男 | 26 | 路飞 | 湖南省永州市 |
| 804 | 孙洋 | 女 | 21 | 乔巴 | 辽宁省阜新市 |
+-----+--------+------+------+--------+--------------------+
6、查询表students所有学员的id、name、class
select id '学号', name '姓名', class '班级' from students;
+--------+-----------+-----------+
| 学号 | 姓名 | 班级 |
+--------+-----------+-----------+
| 801 | 刘海洋 | 乔巴 |
| 802 | 周飞 | 乔巴 |
| 803 | 味全 | 路飞 |
| 804 | 孙洋 | 乔巴 |
| 805 | 李佳 | 超人 |
| 806 | 保总 | 乔巴 |
| 1001 | 徐振永 | 索隆 |
| 1002 | 李卫强 | 索隆 |
| 1003 | 狄枫 | 蜘蛛侠 |
| 1004 | 女屌丝 | 蜘蛛侠 |
| 1005 | 郁燕 | 索隆 |
| 1006 | 裴颖菲 | 索隆 |
| 1007 | 戴小龙 | 索隆 |
+--------+-----------+-----------+
7、选出表students中乔巴和索隆班的学员信息
select * from students where class='乔巴' union select * from students where class='索隆';
select * from students where class='乔巴' or class='索隆';#更优
+------+-----------+------+------+--------+--------------------+
| id | name | sex | age | class | addr |
+------+-----------+------+------+--------+--------------------+
| 801 | 刘海洋 | 男 | 21 | 乔巴 | 北京市海淀区 |
| 802 | 周飞 | 男 | 18 | 乔巴 | 北京市昌平区 |
| 804 | 孙洋 | 女 | 21 | 乔巴 | 辽宁省阜新市 |
| 806 | 保总 | 女 | 30 | 乔巴 | 湖南省衡阳市 |
| 1001 | 徐振永 | 男 | 21 | 索隆 | 辽宁省阜新市 |
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 |
| 1005 | 郁燕 | 女 | 22 | 索隆 | 北京市昌平区 |
| 1006 | 裴颖菲 | 女 | 30 | 索隆 | 辽宁省阜新市 |
| 1007 | 戴小龙 | 男 | 50 | 索隆 | 福建省厦门市 |
+------+-----------+------+------+--------+--------------------+
8、表students中18~25的学员信息
select * from students where age between 18 and 25;
+------+-----------+------+------+-----------+--------------------+
| id | name | sex | age | class | addr |
+------+-----------+------+------+-----------+--------------------+
| 802 | 周飞 | 男 | 18 | 乔巴 | 北京市昌平区 |
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 |
| 801 | 刘海洋 | 男 | 21 | 乔巴 | 北京市海淀区 |
| 804 | 孙洋 | 女 | 21 | 乔巴 | 辽宁省阜新市 |
| 1001 | 徐振永 | 男 | 21 | 索隆 | 辽宁省阜新市 |
| 1004 | 女屌丝 | 女 | 21 | 蜘蛛侠 | 北京市海淀区 |
| 805 | 李佳 | 女 | 22 | 超人 | 福建省厦门市 |
| 1005 | 郁燕 | 女 | 22 | 索隆 | 北京市昌平区 |
+------+-----------+------+------+-----------+-------------------
9、表students中每班人数
select class '班级',count(*) '人数' from students group by class;
+-----------+--------+
| 班级 | 人数 |
+-----------+--------+
| 乔巴 | 4 |
| 索隆 | 5 |
| 超人 | 1 |
| 路飞 | 1 |
| 蜘蛛侠 | 2 |
+-----------+--------+
10、表score中每科最高分
select subject,max(grade) '最高分' from scores group by subject;
+-----------+-----------+
| subject | 最高分 |
+-----------+-----------+
| 中文 | 95 |
| 计算机 | 98 |
| 英语 | 94 |
+-----------+-----------+
11、查询女屌丝的grade和subject
select subject,grade from scores where stu_id=(select id from students where name='女屌丝');
+-----------+-------+
| subject | grade |
+-----------+-------+
| 计算机 | 70 |
| 英语 | 70 |
12、查询两表所有数据的四种连接方式
=连接
select * from students a,scores b where a.id=b.stu_id;
左连接
SELECT * from students a LEFT JOIN scores b on a.id=b.stu_id;
右连接
SELECT * from students a RIGHT JOIN scores b on a.id=b.stu_id;
内连接
SELECT * from students a INNER JOIN scores b on a.id=b.stu_id;
13、每个学员的总成绩
select stu_id '学号',sum(grade)'总成绩' from scores where stu_id=any(select id from students) group by stu_id;
select stu_id '学号',sum(grade)'总成绩' from scores group by stu_id; #这样果然也行
+--------+-----------+
| 学号 | 总成绩 |
+--------+-----------+
| 801 | 178 |
| 802 | 153 |
| 803 | 95 |
| 804 | 162 |
| 805 | 94 |
| 806 | 102 |
| 1001 | 98 |
| 1002 | 153 |
| 1003 | 95 |
| 1004 | 140 |
| 1005 | 94 |
| 1006 | 102 |
| 1007 | 80 |
14、表socres中每科平均成绩
select AVG(grade) '平均成绩' from scores where subject='计算机' union select AVG(grade) '平均成绩' from scores where subject='英语' union select AVG(grade) '平均成绩' from scores where subject='中文';
select subject,avg(grade) from scores group by subject; #真的好省事
+-----------+------------+
| subject | avg(grade) |
+-----------+------------+
| 中文 | 91.5000 |
| 计算机 | 72.5000 |
| 英语 | 75.0000 |
+-----------+------------+
15、计算机成绩低于95的学员信息
select * from students where id=any(select stu_id from scores where grade < 95 and subject='计算机');
+------+-----------+------+------+-----------+--------------------+
| id | name | sex | age | class | addr |
+------+-----------+------+------+-----------+--------------------+
| 802 | 周飞 | 男 | 18 | 乔巴 | 北京市昌平区 |
| 804 | 孙洋 | 女 | 21 | 乔巴 | 辽宁省阜新市 |
| 806 | 保总 | 女 | 30 | 乔巴 | 湖南省衡阳市 |
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 |
| 1004 | 女屌丝 | 女 | 21 | 蜘蛛侠 | 北京市海淀区 |
| 1006 | 裴颖菲 | 女 | 30 | 索隆 | 辽宁省阜新市 |
16、同时参加英语和计算机考试的学员信息
select a.* from students a,scores b,scores c
-> where
-> a.id=b.stu_id
-> and b.subject='英语'
-> and a.id=c.stu_id
-> and c.subject='计算机'
-> ;
+------+-----------+------+------+-----------+--------------------+
| id | name | sex | age | class | addr |
+------+-----------+------+------+-----------+--------------------+
| 801 | 刘海洋 | 男 | 21 | 乔巴 | 北京市海淀区 |
| 804 | 孙洋 | 女 | 21 | 乔巴 | 辽宁省阜新市 |
| 806 | 保总 | 女 | 30 | 乔巴 | 湖南省衡阳市 |
| 1004 | 女屌丝 | 女 | 21 | 蜘蛛侠 | 北京市海淀区 |
| 1006 | 裴颖菲 | 女 | 30 | 索隆 | 辽宁省阜新市 |
17、计算机考试成绩从高到低排列
select grade '计算机成绩' from scores where subject='计算机' order by grade desc;
+-----------------+
| 计算机成绩 |
+-----------------+
| 98 |
| 98 |
| 70 |
| 70 |
| 65 |
| 65 |
| 57 |
| 57 |
+-----------------+
18、表students和scores查询出的学号合并
select id from students union select stu_id from scores;
+------+
| id |
+------+
| 801 |
| 802 |
| 803 |
| 804 |
| 805 |
| 806 |
| 1001 |
| 1002 |
| 1003 |
| 1004 |
| 1005 |
| 1006 |
| 1007 |
+------+
19、索隆班李姓男同学成绩和信息
select * from students where name like '李%' and sex='男' and class='索隆';
+------+-----------+------+------+--------+--------------------+
| id | name | sex | age | class | addr |
+------+-----------+------+------+--------+--------------------+
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 |
+------+-----------+------+------+--------+--------------------+
select grade from scores where stu_id=(select id from students where name like '李%' and sex='男' and class='索隆');
+-------+
| grade |
+-------+
| 88 |
| 65 |
+-------+
select a.*,b.grade from (select * from students where name like '李%' and sex='男' and class='索隆') a,scores b where a.id=b.stu_id; #果然可以
+------+-----------+------+------+--------+--------------------+-------+
| id | name | sex | age | class | addr | grade |
+------+-----------+------+------+--------+--------------------+-------+
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 | 88 |
| 1002 | 李卫强 | 男 | 18 | 索隆 | 福建省厦门市 | 65 |
+------+-----------+------+------+--------+--------------------+-------+
20、来自湖南的学员姓名、班级、年龄、课程、成绩
select name '姓名', age '年龄', class '班级' from students where addr like '湖南%';
+--------+--------+-----------+
| 姓名 | 年龄 | 班级 |
+--------+--------+-----------+
| 味全 | 26 | 路飞 |
| 保总 | 30 | 乔巴 |
| 狄枫 | 26 | 蜘蛛侠 |
+--------+--------+-----------+
select stu_id '学号', grade '成绩', subject '科目' from scores where stu_id=any(select id from students where addr like '湖南%');
+--------+--------+-----------+
| 学号 | 成绩 | 科目 |
+--------+--------+-----------+
| 803 | 95 | 中文 |
| 806 | 57 | 计算机 |
| 806 | 45 | 英语 |
| 1003 | 95 | 中文 |
+--------+--------+-----------+
select a.*,b.grade '成绩',b.subject '科目' from (select id,name '姓名', age '年龄', class '班级' from students where addr like '湖南%') a,scores b where a.id=b.stu_id;
+------+--------+--------+-----------+--------+-----------+
| id | 姓名 | 年龄 | 班级 | 成绩 | 科目 |
+------+--------+--------+-----------+--------+-----------+
| 803 | 天才 | 26 | 路飞 | 95 | 中文 |
| 806 | 保总 | 30 | 乔巴 | 57 | 计算机 |
| 806 | 保总 | 30 | 乔巴 | 45 | 英语 |
| 1003 | 天才 | 26 | 蜘蛛侠 | 95 | 中文 |
21、总成绩小于100的学员姓名改成天才
select stu_id '学号', sum(grade)'总成绩' from scores group by stu_id ;
+--------+-----------+
| 学号 | 总成绩 |
+--------+-----------+
| 801 | 178 |
| 802 | 153 |
| 803 | 95 |
| 804 | 162 |
| 805 | 94 |
| 806 | 102 |
| 1001 | 98 |
| 1002 | 153 |
| 1003 | 95 |
| 1004 | 140 |
| 1005 | 94 |
| 1006 | 102 |
| 1007 | 80 |
+--------+-----------+
update students set name='天才' where id in (803,805,1001,1003,1005,1007);
22、只学过一门课程的学员信息
select count(*),stu_id from scores group by stu_id ;
+----------+--------+
| count(*) | stu_id |
+----------+--------+
| 2 | 801 |
| 2 | 802 |
| 1 | 803 |
| 2 | 804 |
| 1 | 805 |
| 2 | 806 |
| 1 | 1001 |
| 2 | 1002 |
| 1 | 1003 |
| 2 | 1004 |
| 1 | 1005 |
| 2 | 1006 |
| 1 | 1007 |
select count(*),stu_id from scores group by stu_id having count(*)=1;
+----------+--------+
| count(*) | stu_id |
+----------+--------+
| 1 | 803 |
| 1 | 805 |
| 1 | 1001 |
| 1 | 1003 |
| 1 | 1005 |
| 1 | 1007 |
+----------+-------
select * from students a right join (select count(*),stu_id from scores group by stu_id having count(*)=1) b on a.id=b.stu_id ; #=连接也行
+------+--------+------+------+-----------+--------------------+----------+--------+
| id | name | sex | age | class | addr | count(*) | stu_id |
+------+--------+------+------+-----------+--------------------+----------+--------+
| 803 | 天才 | 男 | 26 | 路飞 | 湖南省永州市 | 1 | 803 |
| 805 | 天才 | 女 | 22 | 超人 | 福建省厦门市 | 1 | 805 |
| 1001 | 天才 | 男 | 21 | 索隆 | 辽宁省阜新市 | 1 | 1001 |
| 1003 | 天才 | 男 | 26 | 蜘蛛侠 | 湖南省衡阳市 | 1 | 1003 |
| 1005 | 天才 | 女 | 22 | 索隆 | 北京市昌平区 | 1 | 1005 |
| 1007 | 天才 | 男 | 50 | 索隆 | 福建省厦门市 | 1 | 1007 |
23、年龄一样的学员人数
select count(*),age from students group by age;
+----------+------+
| count(*) | age |
+----------+------+
| 2 | 18 |
| 4 | 21 |
| 2 | 22 |
| 2 | 26 |
| 2 | 30 |
| 1 | 50 |
+----------+------+
select count(*),age from students group by age having count(*) >1;
+----------+------+
| count(*) | age |
+----------+------+
| 2 | 18 |
| 4 | 21 |
| 2 | 22 |
| 2 | 26 |
| 2 | 30 |
+----------+------+
24、每门课程低于平均分的学生姓名、课程名称、分数
#select a.name,b.subject,b.grade from students a,scores b where a.id=b.stu_id;
#select subject,avg(grade) GPA from scores group by subject;
select st.*,avg.GPA from (select a.name,b.subject,b.grade from students a,scores b where a.id=b.stu_id) st,(select subject,avg(grade) GPA from scores group by subject) avg where st.subject=avg.subject and st.grade<avg.GPA;
| name | subject | grade | GPA |
+-----------+-----------+-------+---------+
| 周飞 | 计算机 | 65 | 72.5000 |
| 周飞 | 中文 | 88 | 91.5000 |
| 孙洋 | 计算机 | 70 | 72.5000 |
| 保总 | 计算机 | 57 | 72.5000 |
| 保总 | 英语 | 45 | 75.0000 |
| 李卫强 | 中文 | 88 | 91.5000 |
| 李卫强 | 计算机 | 65 | 72.5000 |
| 女屌丝 | 计算机 | 70 | 72.5000 |
| 女屌丝 | 英语 | 70 | 75.0000 |
| 裴颖菲 | 计算机 | 57 | 72.5000 |
| 裴颖菲 | 英语 | 45 | 75.0000 |
25、每个人成绩最高的课程名称及分数
select a.name,b.subject,b.grade from students a,scores b where b.grade in (select max(grade) maximum from scores group by stu_id)and a.id=b.stu_id;+-----------+-----------+-------+
| name | subject | grade |
+-----------+-----------+-------+
| 刘海洋 | 英语 | 80 |
| 刘海洋 | 计算机 | 98 |
| 周飞 | 中文 | 88 |
| 天才 | 中文 | 95 |
| 孙洋 | 计算机 | 70 |
| 孙洋 | 英语 | 92 |
| 天才 | 英语 | 94 |
| 保总 | 计算机 | 57 |
| 天才 | 计算机 | 98 |
| 李卫强 | 中文 | 88 |
| 天才 | 中文 | 95 |
| 女屌丝 | 计算机 | 70 |
| 女屌丝 | 英语 | 70 |
| 天才 | 英语 | 94 |
| 裴颖菲 | 计算机 | 57 |
| 天才 | 英语 | 80 |
SELECT a.id '学号', a.name '姓名', b.subject '课程名称', MAX(b.grade) '最高分' FROM students a,scores b WHERE b.stu_id=a.id GROUP BY b.stu_id;
+--------+-----------+--------------+-----------+
| 学号 | 姓名 | 课程名称 | 最高分 |
+--------+-----------+--------------+-----------+
| 801 | 刘海洋 | 英语 | 98 |
| 802 | 周飞 | 计算机 | 88 |
| 803 | 天才 | 中文 | 95 |
| 804 | 孙洋 | 计算机 | 92 |
| 805 | 天才 | 英语 | 94 |
| 806 | 保总 | 计算机 | 57 |
| 1001 | 天才 | 计算机 | 98 |
| 1002 | 李卫强 | 中文 | 88 |
| 1003 | 天才 | 中文 | 95 |
| 1004 | 女屌丝 | 计算机 | 70 |
| 1005 | 天才 | 英语 | 94 |
| 1006 | 裴颖菲 | 计算机 | 57 |
| 1007 | 天才 | 英语 | 80 |
mysql语句查询练习的更多相关文章
- Thinkphp用exp表达式执行mysql语句,查询某字段不为空is not null,自动增值
Thinkphp用exp表达式执行mysql语句,查询某字段不为空is not null,自动增值 Thinkphp 的文档经常不够完整的表达MYSQL的各种组合,is not null在thinkp ...
- mysql语句查询时间检测
explain的使用 1.首先我们是要登入你的mysql的,然后选择数据库输入:use 你要选择的库名 2执行语句 eg: explain SELECT * FROM wish_orders1412 ...
- mysql语句查询:查询距离某个日期10天的数据
select * from table where state = '1' and DATE_SUB(CURDATE(), INTERVAL 10 DAY) <= begin_time
- Mysql 慢查询设置
Mysql慢查询设置 分析MySQL语句查询性能的方法除了使用 EXPLAIN 输出执行计划,还可以让MySQL记录下查询超过指定时间的语句,我们将超过指定时间的SQL语句查询称为“慢查询”. === ...
- MySQL慢查询详解
分析MySQL语句查询性能的方法除了使用 EXPLAIN 输出执行计划,还可以让MySQL记录下查询超过指定时间的语句,我们将超过指定时间的SQL语句查询称为“慢查询”. 查看/设置“慢查询”的时 ...
- 《MySQL》一次MySQL慢查询导致的故障
本文转载自 http://www.jb51.net/article/70955.htm 我们知道分析MySQL语句查询性能的方法除了使用EXPLAIN 输出执行计划,还可以让MySQL记录下查询超过指 ...
- mysql分页原理和高效率的mysql分页查询语句
该博来自网络转载!!!供自己学习使用!!! 以前我在mysql中分页都是用的 limit 100000,20这样的方式,我相信你也是吧,但是要提高效率,让分页的代码效率更高一些,更快一些,那我们又该怎 ...
- 如何查找MySQL中查询慢的SQL语句
如何查找MySQL中查询慢的SQL语句 更多 如何在mysql查找效率慢的SQL语句呢?这可能是困然很多人的一个问题,MySQL通过慢查询日志定位那些执行效率较低的SQL 语句,用--log-slow ...
- 23个MySQL常用查询语句
23个MySQL常用查询语句 一查询数值型数据: SELECT * FROM tb_name WHERE sum > 100; 查询谓词:>,=,<,<>,!=,!> ...
随机推荐
- 判断一个值是否为null或者undefined
var a=null; var b=undefined; if(a===null){ //a==null alert("a=null") }else{ alert("a= ...
- Java集合专题总结(1):HashMap 和 HashTable 源码学习和面试总结
2017年的秋招彻底结束了,感觉Java上面的最常见的集合相关的问题就是hash--系列和一些常用并发集合和队列,堆等结合算法一起考察,不完全统计,本人经历:先后百度.唯品会.58同城.新浪微博.趣分 ...
- OCP考点实战演练02-日常维护篇
本系列宗旨:真正掌握OCP考试中所考察的技能,坚决不做Paper OCP! 实验环境:RHEL 6.4 + Oracle 11.2.0.4 OCP考点实战演练02-日常维护篇 1.数据库体系结构和AS ...
- Vertica 分区表设计
Vertica数据库中的表只是一个逻辑概念. 实际存储在磁盘上的是projection. 当创建一张表,没有创建projection时,那么插入数据的时候会自动创建一个默认的projection.如果 ...
- SQL连接
SQL连接可以分为内连接.外连接.交叉连接. 数据库数据: book表 stu表 1.内连接 ...
- Http协议相关内容
http协议概述 HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义浏览器与WEB服务器之间交换数据的过程. 客户 ...
- 浅谈UML的概念和模型之UML九种图
1.用例图(use case diagrams) [概念]描述用户需求,从用户的角度描述系统的功能 [描述方式]椭圆表示某个用例:人形符号表示角色 [目的]帮组开发团队以一种可视化的方式理解系统的功能 ...
- Angularjs环境搭建
Angularjs架构搭建 1.搭建Angularjs项目 1)在package.json中配置如下,然后 npm install下载包 { "na ...
- Android Time类 奇葩的设定
Android 的Time.MONTH默认是0-11表示1-12月,小白表示坑爹啊,浪费多少精力啊.
- [更新设计]跨平台物联网通讯框架ServerSuperIO 2.0 ,功能、BUG、细节说明,以及升级思考过程!
注:ServerSuperIO 2.0 还没有提交到开源社区,在内部测试!!! 1. ServerSuperIO(SSIO)说明 SSIO是基于早期工业现场300波特率通讯传输应用场景发展.演化而来. ...