Title: Pull user database with mysql query?
Last modified: August 30, 2016

---

# Pull user database with mysql query?

 *  [funeral](https://wordpress.org/support/users/funeral/)
 * (@funeral)
 * [11 years ago](https://wordpress.org/support/topic/pull-user-database-with-mysql-query/)
 * Hello I was wondering if anyone could point my in n the right direction. What
   I’m trying to do is create a clan roster and use the wordpress user id’s that
   way I don’t have to keep re-entering them via html.

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

 *  [yorman](https://wordpress.org/support/users/yorman/)
 * (@yorman)
 * [11 years ago](https://wordpress.org/support/topic/pull-user-database-with-mysql-query/#post-6252208)
 * I do not know what _“clan roster”_ is, and when I search that term on the Internet
   there is only things related to video game teams. Anyway, you can extract the
   user’s data from the WordPress database with a SQL query like this, where _“wp\
   _users”_ is the name of the table:
 *     ```
       SELECT * FROM wp_users ORDER BY ID ASC;
       ```
   
 * And if you want to combine this query with the WordPress functions then you can
   use the global variable _“wpdb”_ and the _“get\_results”_ method to extract the
   information in a way that you can manipulate with PHP, like this:
 *     ```
       global $wpdb;
       if ( $wpdb ) {
         $query = 'SELECT * FROM wp_users ORDER BY ID ASC';
         $results = $wpdb->get_results( $query, OBJECT );
         var_dump( $results );
       }
       ```
   
 *  Thread Starter [funeral](https://wordpress.org/support/users/funeral/)
 * (@funeral)
 * [11 years ago](https://wordpress.org/support/topic/pull-user-database-with-mysql-query/#post-6252212)
 * Yeah im trying to build a clan roster with certain users registered on my site
   
   so lets say clan leader is wordpress id 1/or specific username co-leader is another
   id/specific name
 * creating a table to put these in i just dont know how to grab specific names 
   i want
 * thanks for the help! trying to learn queries here hah!
 *  [yorman](https://wordpress.org/support/users/yorman/)
 * (@yorman)
 * [11 years ago](https://wordpress.org/support/topic/pull-user-database-with-mysql-query/#post-6252217)
 * To extract the data of an user following a filter you can use the keyword _“WHERE”_
   in conjunction with the _“SELECT”_ statement as you can see here [1]. Following
   my previous example, you could run a SQL query like this to extra the information
   of one user account.
 *     ```
       SELECT * FROM wp_users WHERE user_login = 'admin' LIMIT 1;
       ```
   
 * WordPress has a page with information [2] of how to use the global variable _“
   wpdb”_ to query the database, so if you want to learn a few tricks to customize
   your website check that reference.
 * [1] [https://dev.mysql.com/doc/refman/5.7/en/select.html](https://dev.mysql.com/doc/refman/5.7/en/select.html)
   [
   2] [https://codex.wordpress.org/Class_Reference/wpdb](https://codex.wordpress.org/Class_Reference/wpdb)

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

The topic ‘Pull user database with mysql query?’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [yorman](https://wordpress.org/support/users/yorman/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/pull-user-database-with-mysql-query/#post-6252217)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
