Home > Backend Development > PHP Tutorial > The script executes mysql to query the corresponding data in half an hour

The script executes mysql to query the corresponding data in half an hour

WBOY
Release: 2016-07-28 08:27:56
Original
1271 people have browsed it

SELECT
COUNT(logb.id)
FROM
rm_operate_log
WHERE CONCAT(
DATE_FORMAT(create_date, '%Y%m%d%H-'),
IF (
) DATE_FORMAT(create_date, '%i') > 30 ,
1,
0
)
) = CONCAT(
DATE_FORMAT(NOW(), '%Y%m%d%H-'),
IF (DATE_FORMAT(NOW(), '%i') > 30 , 1, 0)

)

The server has a script to grab data from the database every 30 minutes and then send push messages

1.DATE_FORMAT(create_date, '%Y%m%d%H-') Query create_date in the database Time format 'Year Month Day -'

2. DATE_FORMAT(create_date, '%i') > 30,
1,
0
) Query the time format of create_date in the database 'minutes' If greater than 30, it is 1 otherwise it is 0

3. Use concat() to connect the two strings

4 and then compare it with the current time

The above has introduced the script to execute mysql to query the corresponding data in half an hour, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template