

Get in touch

Download Plugin Now
  • Follow
  • Follow
WP Data Access
  • Download
  • Support
  • Features
  • Pricing
  • Documentation
    • Tool Guide
    • App Builder
    • Data Explorer
    • SQL Query Builder
    • Plugin Settings
    • Legacy Tools
    • Remote Connections
a
M
M
  • Download
  • Support
  • Features
  • Pricing
  • Documentation
    • Tool Guide
    • App Builder
    • Data Explorer
    • SQL Query Builder
    • Plugin Settings
    • Legacy Tools
    • Remote Connections
Download Plugin Now

SQL Query Builder

  • Getting Started
  • Tutorials
  • Visual Query Builder
  • Writing queries
  • Data exchange
  • Stored procedures
  • Database triggers
  • Scheduled queries
  • WordPress user ID in SQL
View Categories

Scheduled queries

It is possible to use MySQL events to execute queries at regular intervals. Conceptually, this is similar to the Unix crontab and the Windows Task Scheduler. The example below truncates my demo table and adds five rows every 60 seconds.
CREATE EVENT demo_event
	ON SCHEDULE EVERY 60 SECOND DO
BEGIN
	DECLARE i INTEGER;
	SET i = 0;

	TRUNCATE TABLE demo;

	WHILE i < 5 DO
	  INSERT INTO demo VALUES (i);
	  SET i = i + 1;
	END WHILE;
END
/

Notes #

  • The event scheduler needs to run to execute events (check with show processlist)
  • Read more about the MySQL event scheduler
Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Updated on 2025-02-07

Submit a Comment Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents
  • Notes
WP Data Access
  • Follow
  • Follow
Quick Links
$

Blogs

$

Tutorials

$

Demos

Get in touch
$

Premium support

$

Free support forum

$

Contact us

Resources


WordPress plugin directory



YouTube tutorials

Copyright © 2025 | All Right Reserves

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok