Count number of rows added last hours MySQL

By October 10, 2016MYSQL, PHP

The following query display the count number of rows added last hours MySQL.

Function used : DATE_SUB(), NOW()

SELECT 
  COUNT(*) AS cnt 
FROM
  `user` `ur` 
WHERE ur.added_time >= DATE_SUB(NOW(), INTERVAL 1 HOUR);

SELECT DATE_SUB(NOW(), INTERVAL 1 HOUR);

Pankaj Singh Sugara

Author Pankaj Singh Sugara

Experienced Software Engineer with a demonstrated history of working in the marketing and advertising industry. Skilled in SQL, Web Applications, PHP, WordPress, and Joomla. Strong engineering professional with a B-TECH focused in Information Technology from JCDM College of Engineering Sirsa, Haryana.

More posts by Pankaj Singh Sugara