How does mysql query all the data on the penultimate day in the table?
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!