Title: SQL USE DB
Last modified: February 16, 2018

---

# SQL USE DB

 *  [Terrence LP](https://wordpress.org/support/users/terrence-lp/)
 * (@terrence-lp)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/sql-use-db/)
 * Hello,
 * I would like to know if I can ‘USE’ a different DB for displaying custom data.
   The Table tab sees this table and that part works. But I need a custom query 
   and doing this on the Query tab produces errors.
 * How can I access the non WordPress db?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [rweil55](https://wordpress.org/support/users/rweil55/)
 * (@rweil55)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/sql-use-db/#post-9981782)
 * try
 * “WP_Tables does not directly support custom SQL queries, However if you use phpMyAdmin
   to create a view, then WP_Tables can display that view.”
 *  Plugin Author [Ian Sadovy](https://wordpress.org/support/users/iansadovy/)
 * (@iansadovy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/sql-use-db/#post-9988573)
 * Hello [@terrence-lp](https://wordpress.org/support/users/terrence-lp/),
 * Thank you for the question.
    To run the query for the different databases on 
   the server, please make sure that the MySQL user for wordpress db also has read
   permissions for other databases you want to access. It can be done by using [PhpMyAdmin](https://docs.phpmyadmin.net/en/latest/privileges.html#assigning-privileges-to-user-for-a-specific-database)
   or [GRANT statement](https://dev.mysql.com/doc/refman/5.7/en/grant.html).
 * Hope it helps.
 * Regards,
    Ian
 *  Thread Starter [Terrence LP](https://wordpress.org/support/users/terrence-lp/)
 * (@terrence-lp)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/sql-use-db/#post-10008527)
 * Hello,
 * Great Plugin – Needs a Filter feature! Like Filter By (what ever we have in the
   columns)
 * But to answer the ‘USE DB’ what I was able to do was set up MySQL permissions
   so my WP User also has access to the other or External DB.
 * From there I just call the DB like so –
 *     ```
       SELECT article.id, SUM(article_text.word_count) as total_words
       FROM master_media.article
       ```
   
 * As long as that is specified it all works great!
 * I’m even using SUM, JOINS, GROUP BY and ORDER BY’s all in the same query and 
   works great .
    -  This reply was modified 8 years, 3 months ago by [Terrence LP](https://wordpress.org/support/users/terrence-lp/).
 *  Plugin Author [Ian Sadovy](https://wordpress.org/support/users/iansadovy/)
 * (@iansadovy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/sql-use-db/#post-10014698)
 * Hello [@terrence-lp](https://wordpress.org/support/users/terrence-lp/),
 * I am glad to hear it works.
    As for the filtering feature, I see many requests
   for that, so I will try to prioritize the development.
 * Thanks,
    Ian

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘SQL USE DB’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wptables_c8eafa.svg)
 * [WordPress Tables](https://wordpress.org/plugins/wptables/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wptables/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wptables/)
 * [Active Topics](https://wordpress.org/support/plugin/wptables/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wptables/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wptables/reviews/)

## Tags

 * [db](https://wordpress.org/support/topic-tag/db/)
 * [other](https://wordpress.org/support/topic-tag/other/)
 * [use](https://wordpress.org/support/topic-tag/use/)

 * 4 replies
 * 3 participants
 * Last reply from: [Ian Sadovy](https://wordpress.org/support/users/iansadovy/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/sql-use-db/#post-10014698)
 * Status: not resolved