

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
  • 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
  • Writing queries
  • AI Assistant
  • Schedule queries
  • Data exchange
  • WordPress user ID in SQL
  • Stored procedures
  • Database triggers
  • Visual Query Builder
View Categories

Data exchange

Each tab in the Query Builder is connected to a single database at a time. While the USE command allows switching to another database within a query, you cannot maintain simultaneous connections to two databases in the same query. As a result, it’s not possible to directly copy data between databases using standard SQL.

To solve this limitation, WP Data Access introduces two custom plugin commands that enable cross-database data exchange. These are not native MySQL commands — they are available only within the Query Builder.

WPDAVAR (or wpdavar) #

The WPDAVAR command stores the result of the last executed query into a plugin variable. For example, the following code selects all rows from the genre table and saves the result into a variable named my_genres:

select * from genre
/

wpdavar my_genres
/

WPDATMP (or wpdatmp) #

The WPDATMP command creates a temporary table from a variable that was previously set with WPDAVAR. The temporary table will use the same name as the variable:

select * from genre
/

wpdavar my_genres
/

use rdb:my_remote_database
/

wpdatmp my_genres
/

Exchanging data between different databases #

Combining WPDAVAR and WPDATMP allows you to exchange data between two databases. This works for local and remote databases.

Example syncing the genre table from a remote database to WordPress #

-- Select from remote DB
use rdb:my_remote_database
/

select * from genre
/

-- Store results in a temporary table
wpdavar my_genres
/

-- Switch to WordPress DB
use wordpress
/

wpdatmp my_genres
/

-- Insert missing genres
insert into genre select * from my_genres
where genre_name not in (select genre_name from genre)
/

Important #

  • Test your query/queries before you schedule
  • Make sure you handle all possible exceptions
  • A failing query prevents execution of subsequent queries

Limitations #

The synching example temporarily loads the entire dataset into memory. For large tables, this may cause memory issues or execution failure. In such cases, you should split the operation into smaller chunks, using LIMIT/OFFSET or other filtering techniques.

Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Updated on 2025-05-22
Schedule queriesWordPress user ID in SQL

2 Comments

  1. Hardeep kumar
    Hardeep kumar on 2025-05-27 at 6:15 pm

    How we can enable multiple registered users update a single database real time? Just like a bidding system. Is it possible with this plug-in? can we implement ajax to show real-time data?

    Reply
    • Kim Leong
      Kim Leong on 2025-05-28 at 8:13 am

      Hi Hardeep,

      Multiple logged-in users can update your database tables as long as your server can handle it. If you’re presenting data using the App Builder, there’s a hook you can implement to refresh/reload a table at specific time intervals.

      See here: https://wpdataaccess.com/docs/hooks-examples/auto-reload-table-at-specific-intervals/

      Hope that helps! If you have more questions, you may send us a message via our contact page.

      Reply

Submit a Comment Cancel reply

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

Table of Contents
  • WPDAVAR (or wpdavar)
  • WPDATMP (or wpdatmp)
  • Exchanging data between different databases
  • Important
  • Limitations
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