Order by in sql injection

The order by in the joint query must be familiar to everyone. The ORDER BY statement is used to sort the result set according to the specified column. If there is a table Orders as follows

1. Show company names in alphabetical order

SELECT Company, OrderNumber FROM Orders ORDER BY Company

The results are as follows, sorted in ascending order by company name

In fact, the above order by Company can be written as order by 1, that is, sort by the first column of the table, Company, order by n, that is, sort by the nth column of the table, when the number in the sorted column exceeds the original number of columns An error such as (Unknown column '4' in'order clause') will be reported, so there is order by n in the joint query.

select * from 表名 order by 列名(或者数字) asc;升序(默认升序)   #数字就是代替列名字
select * from 表名 order by 列名(或者数字) desc;降序

 

Guess you like

Origin blog.csdn.net/qq_44159028/article/details/114809458