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; 查询谓词:>,=,<,<>,!=,!> ...
随机推荐
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(34)-文章发布系统①-简要分析
系列目录 最新比较闲,为了学习下Android的开发构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(1)-前言与,虽然有点没有目的的学习,但还是了解了Andro ...
- linq to entity常用操作
一.聚合函数查询 ; using (xxxEntities db = new xxxEntities()) { sum = db.userinfo.AsNoTracking().Where(d =&g ...
- console.log("A"-"B"+"3")=?
(点击上方的订阅号,可快速关注,关注有惊喜哦^_^) 前不久看到一道JS基础题目,做了一下竟然错了一半...在此分享一下: 先把题目放上来,大家可以自己测试一下再看答案哦^_^ ①console.lo ...
- Unity3D中常用的数据结构总结与分析
来到周末,小匹夫终于有精力和时间来更新下博客了.前段时间小匹夫读过一份代码,对其中各种数据结构灵活的使用赞不绝口,同时也大大激发了小匹夫对各种数据结构进行梳理和总结的欲望.正好最近也拜读了若干大神的文 ...
- 利用Python进行数据分析(14) pandas基础: 数据转换
数据转换指的是对数据的过滤.清理以及其他的转换操作. 移除重复数据 DataFrame里经常会出现重复行,DataFrame提供一个duplicated()方法检测各行是否重复,另一个drop_dup ...
- Create an offline installation of Visual Studio 2017 RC
Create an offline installation of Visual Studio 2017 RC 2016年12月7日 ...
- php:ci学习笔记1
ci下载的开发包: phpstudy的部署: phpstudy的根目录是:D:\WWW 新建目录 cms 把ci开发包的application system index.php lic ...
- 最小生成树计数 bzoj 1016
最小生成树计数 (1s 128M) award [问题描述] 现在给出了一个简单无向加权图.你不满足于求出这个图的最小生成树,而希望知道这个图中有多少个不同的最小生成树.(如果两颗最小生成树中至少有一 ...
- stm32新建工程详细步骤
记得好早以前为了建一个keil的工程折腾了好久,在这里写写基本的Keil工程创建方法,以防自己以后再忘记: 新建工程 保存工程 选择器件 在这边新建文件夹,然后就是添加程序代码到里面去了.其中一些文件 ...
- Linux:JDK配置
1.JDK官网下载"jdk-8u101-linux-i586.tar.gz",32位或64位. 2 命令 #创建jdk所在目录 sudo mkdir /usr/lib/jvm #找 ...