How to  delete from multiple Database

Nura111
Nura111 used Ask the Experts™
on
I want to perform a delete query as the next one
on different databases
DELETE FROM wp_posts WHERE post_type = "revision";
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Walter RitzelSenior Software Engineer

Commented:
That should be one database at a time. In the same way I have answered you before, you can have one user account with permissions on several other database and from this account you can issue commands like this:

DELETE FROM <database name>.wp_posts WHERE post_type = "revision";

Author

Commented:
yes all the databases are in one place can i
DELETE FROM <database name>.wp_posts WHERE post_type = "revision";
union  <database name>.wp_posts
union   <database name>.wp_posts

Commented:
you are better off using the Class provided to you by Wordpress for interacting with the database

http://codex.wordpress.org/Function_Reference/wpdb_Class

More specifically, delete posts with wp_delete_post() or risk leaving behind things like comments and meta data.

http://codex.wordpress.org/Function_Reference/wp_delete_post

Senior Software Engineer
Commented:
No, there is no union in delete command. You should issue one at a time.
DELETE FROM <database name>.wp_posts WHERE post_type = "revision";
DELETE FROM <database name>.wp_posts WHERE post_type = "revision";
DELETE FROM <database name>.wp_posts WHERE post_type = "revision";

Commented:
Sorry, just realized you were trying to only delete revisions.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial