当前位置:网站首页>Database basics exercise part 2
Database basics exercise part 2
2022-07-06 06:45:00 【Lu__ xiao】
MYSQL(MariaDB) Advanced operation
- order by Usage of
select * from result order by score desc;
take result Data installation scores in the table (score) Sort high and low
among ,desc Representation of descending order ( Decline ); If from low to high ( Ascending ) Arrange , Then you can put desc Switch to asc; If you don't add this parameter , By default, they are arranged in ascending order

select id,name,score from result order by 1;
take result The data in the table is displayed by id Sort

select id,name,score from result order by 2;
take result The data in the table is displayed by name Sort

select id,name,score from result order by 3;
take result The data in the table is displayed by score Sort

select id,name,score from result order by 4;
Prompt error No fourth column
order by Back number (M) Must be less than n( Number of fields in database query ) To display properly . If M>N, The database will report an error

- Limit Usage of
Limit M,N // Says from the first M+1 Data began to look down N Data
Limit M // Indicates before query M Data
select * from result limit 0,2;
The first... In the query table 2 Data

select id,name,score from result limit 1,3;
From 2 Data starts , Go down to query 3 Of data id、name and score Field

- union select Usage of
(1)select * from result union select 1,2,3,4;
The query result of this statement , That is select * from result and union select 1,2,3,4 Splicing of query results

(2) Try the following 3 statement :
select id,name,score from result union select 1,2,3;

Normal display
select id,name,score from result union select 1,2;

Report errors
select id,name,score from result union select 1,2,3,4;

Report errors
The above results are summarized , For the following commands :
Select c1,c2…,cn from result union select d1,d2,…dm;
The second half of the sentence union select Number of fields queried (M) Must be the same as the first half of the sentence select Number of fields queried (n) equal , The database can display the results normally . And order by be similar , This feature can be used to judge the number of fields queried in the database .
(3) Try the following statement
select id,city from result where id=1 and 1=2 union select name,score from result;

From the above results, we can sum up , When the field name is known , An attacker simply places the field anywhere it can be displayed , You can expose the value of this field 、
- union select combination information_schema database
MySQL (MariaDB) 5.5 The above version comes with information schema database , It's about MySQL Information about all other databases maintained by the server , Such as database name, database table 、 Data type and access right of table column . You can put information schema Database as MySQL (MariaDB) Of ” Catalog "!
- Try to execute the following two statements
Show databases;
Select schema_name from information_schema.schemata;


The execution results of the two statements are the same
(2) Try to execute the following two sets of statements
The first group
Use student;
The second group
select table_name from information_schema.tables where table_schema='student';


The execution results of the two groups of commands are the same
边栏推荐
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- How do programmers remember code and programming language?
- Day 248/300 关于毕业生如何找工作的思考
- Leetcode - 152 product maximum subarray
- Leetcode daily question (971. flip binary tree to match preorder traversal)
- Day 245/300 JS foreach data cannot be updated to the object after multi-layer nesting
- Office-DOC加载宏-上线CS
- 【刷题】怎么样才能正确的迎接面试?
- AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm
- Thesis abstract translation, multilingual pure human translation
猜你喜欢

红蓝对抗之流量加密(Openssl加密传输、MSF流量加密、CS修改profile进行流量加密)

端午节快乐Wish Dragon Boat Festival is happy
![[ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)](/img/02/41dcdcc6e8f12d76b9c1ef838af97d.png)
[ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)

Transfert des paramètres de la barre d'adresse de la page de liste basée sur jeecg - boot

LeetCode 731. My schedule II

Fedora/REHL 安装 semanage

MySQL5.72. MSI installation failed

Office doc add in - Online CS

Apache dolphin scheduler source code analysis (super detailed)

生物医学英文合同翻译,关于词汇翻译的特点
随机推荐
SQL Server Manager studio (SSMS) installation tutorial
云服务器 AccessKey 密钥泄露利用
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Address bar parameter transmission of list page based on jeecg-boot
如何将flv文件转为mp4文件?一个简单的解决办法
CS certificate fingerprint modification
[English] Verb Classification of grammatical reconstruction -- English rabbit learning notes (2)
Grouping convolution and DW convolution, residuals and inverted residuals, bottleneck and linearbottleneck
Changes in the number of words in English papers translated into Chinese
机器人类专业不同层次院校课程差异性简述-ROS1/ROS2-
Suspended else
The registration password of day 239/300 is 8~14 alphanumeric and punctuation, and at least 2 checks are included
How effective is the Chinese-English translation of international economic and trade contracts
[brush questions] how can we correctly meet the interview?
mysql的基础命令
My daily learning records / learning methods
It is necessary to understand these characteristics in translating subtitles of film and television dramas
Monotonic stack
详解SQL中Groupings Sets 语句的功能和底层实现逻辑
Biomedical localization translation services