

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

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
    • Example syncing the genre table from a remote database to WordPress
  • Important
  • Limitations
WP Data Access
  • Follow
  • Follow
Links
$

Imprint

$

Privacy policy

$

Cookie policy

Get in touch
$

Contact us

$

Free support forum

$

Premium support

Resources


WordPress plugin directory



YouTube tutorials

Copyright © 2025 | All Right Reserves

Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}