MySQL checks the last record at the end of the month

Artificial intelligence, zero-based entry! http://www.captainbed.net/inner 

The first method: select the time range, and then sort in reverse order, use the limit keyword to check only the first row is the last record

select * from order where order_time>='2019-10-01'and order_time<'2019-11-01' order by order_time desc limit 1;

The second method: the primary key id of the database table is generally set to self-increase, so directly find the largest id is the last record

select  * from order where id = (select max(id) from order);

 I have encountered this requirement in business, so record it!

Guess you like

Origin blog.csdn.net/qq_35860138/article/details/102951541