Title: sql query on a custom controller
Last modified: August 30, 2016

---

# sql query on a custom controller

 *  [skel77](https://wordpress.org/support/users/skel77/)
 * (@skel77)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-query-on-a-custom-controller/)
 * Hi
 * I need to run a query on a WP table and return the results. I count find any 
   examples on this.
 * I need to know if I could use the global $wpdb value and run a sql command like
   in a normal WP page or if there is another way to do this.
 * I tried the $wpdb way and it doesn’t seem to work. Struggling with this for days.
 * thanks in advance
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

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

 *  Thread Starter [skel77](https://wordpress.org/support/users/skel77/)
 * (@skel77)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-query-on-a-custom-controller/#post-6682148)
 * My Bad. it was coding error. And you can use $wpdb and run any sql query.
 * I love this plugin 🙂
 *  [chrishaff](https://wordpress.org/support/users/chrishaff/)
 * (@chrishaff)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/sql-query-on-a-custom-controller/#post-6682439)
 * Wait, could you please provide an example?

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

The topic ‘sql query on a custom controller’ is closed to new replies.

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

## Tags

 * [database access](https://wordpress.org/support/topic-tag/database-access/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 2 replies
 * 2 participants
 * Last reply from: [chrishaff](https://wordpress.org/support/users/chrishaff/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/sql-query-on-a-custom-controller/#post-6682439)
 * Status: not resolved