Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does mysql query all the data on the penultimate day in the table?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "mysql how to query all the data on the penultimate day in the table". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "mysql how to query all the data on the penultimate day in the table".

For all employees who query the penultimate entry date of the employee table, take into account the employees who have joined on the same day, so use this date to find out the penultimate date first, and then use this date to query all equivalent employee information.

SELECT * FROM `employees`Were `hire_ date` = (SELECT DISTINCT `hire_ date`FROM `employees`ORDER BY `hire_ date` DESC LIMIT 2,1)

CREATE

Drop table if exists `employees`; CREATE TABLE `employees` (`first_ no` int (11) NOT NULL, `birth_ date` date NOT NULL, `first_ name` varchar (14) NOT NULL, `last_ name` varchar (16) NOT NULL, `gender` char (1) NOT NULL, `hire_ date` date NOT NULL,)

INSERT

INSERT INTO `employees` (`emp_ no`, `birth_ date`, `first_ name`, `last_ name`, `gender`, `hire_ date`) VALUES (1, '2021-08-04,' Georgi', 'Facello',' Manners, '1980-06-21') INSERT INTO `employees` (`emp_ no`, `birth_ date`, `first_ name`, `last_ name`, `gender`, `hire_ date`) VALUES (2, '2021-08-20 years,' Bezalel', 'Simnel',' dates, '1985-11-21') INSERT INTO `employees` (`emp_ no`, `birth_ date`, `first_ name`, `last_ name`, `gender`, `hire_ date`) VALUES (3, '2021-08-20 years,' Parto', 'Bamford',' Manners, '1986-08-28') INSERT INTO `employees` (`emp_ no`, `birth_ date`, `first_ name`, `last_ name`, `gender`, `hire_ date`) VALUES (4, '2021-08-20,' Chirstian', 'Koblick',' Manners, '1986-12-01') Thank you for your reading, the above is the content of "mysql how to query all the data on the penultimate day of the table". After the study of this article, I believe you have a deeper understanding of how mysql queries all the data on the penultimate day of the table, and the specific use still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report