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; 查询谓词:>,=,<,<>,!=,!> ...
随机推荐
- C++服务器开发之笔记三
为什么需要原子性操作? 我们考虑一个例子:(1)x++这个常见的运算符在内存中是怎样操作的?从内存中读x的值到寄存器中,对寄存器加1,再把新值写回x所处的内存地址 若是有两个线程同时对同一个变量++, ...
- CSS3中的动画效果记录
今天要记录的是CSS3中的三种属性transform.transition以及animation,这三个属性大大提升了css处理动画的能力. 一.Transform 变形 CSS中transform ...
- 父页面操作iframe子页面的安全漏洞及跨域限制问题
一.父子交互的跨域限制 同域情况下,父页面和子页面可以通过iframe.contentDocument或者parent.document来交互(彼此做DOM操作等,如父页面往子页面注入css). 跨域 ...
- C站投稿189网盘视频源(UP主篇)
C站投稿189网盘视频源(UP主篇) 现在C站(吐槽弹幕网)的视频来源基本靠的都是189网盘,比如番剧区的每个视频基本来源于此,不像AB两站,拥有自己的资源服务器,为啥呢?没钱啊.都是外来的视频.本站 ...
- 在thinkphp中,写的博文标签多对多关系的标签频率统计算法
常常看到别人的博客里面,或者网站里面有这样随机颜色,但字体大小与标签出现频率有关的标签云,于是自己就想写一个.至于颜色的随机显示,那就很简单了,这里就不列代码. 因为正在学thinkphp,所以数据查 ...
- Centos 上 Tengine安装
安装步骤: 1.系统环境 1.1 更新系统 [root@centos ~]# yum update -y 1.2 查看环境 [root@centos ~]# cat /etc/redhat-relea ...
- Spring JdbcTemplate
参考链接: https://my.oschina.net/u/437232/blog/279530 http://jinnianshilongnian.iteye.com/blog/1423897 J ...
- 基础笔记(一):C#编程要点
前言 来源于手中日常摘录的资料和书籍,算是对看过的东西的总结,部分注有阅读心得,也有部分只提出大纲或结论.(备注:本篇文章中大部分要点需要有实际的开发经验,有助于阅读理解.) 目录 const ...
- C++_系列自学课程_第_12_课_结构体
#include <iostream> #include <string> using namespace std; struct CDAccount { double bal ...
- GJM: 设计模式 - 模板方法模式(Template Method)
生活中的模板 一.在银行办理业务 Step1:进门取号 Step2:填写单据 Step3:等待叫号 Step4:窗口办理 二.奥运会开幕式 第一步:升国旗奏国歌 第二步:领导人致辞讲话 第三部: 文艺 ...