Title: How does one query the database?
Last modified: November 13, 2016

---

# How does one query the database?

 *  Resolved [adamglatt](https://wordpress.org/support/users/adamglatt/)
 * (@adamglatt)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/how-does-one-query-the-database/)
 * Firstly, thank you for developing this plugin. It’s fantastic.
 * I’d like to query the data but am having issues aggregating. Can someone assist
   with the sample query below?
 *     ```
       SELECT
       IF(ev.slug='user_id', ev.value, NULL) as user_id
       IF(ev.slug='date', ev.value, NULL) as date
       FROM table_name ev
       ```
   
 * This gives me the values I want, but also all the NULLS inbetween. How can I 
   aggregate or group the results?
 * I tried a simple GROUP BY user_id, but get an error. Any help is greatly appreciated!

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

 *  Thread Starter [adamglatt](https://wordpress.org/support/users/adamglatt/)
 * (@adamglatt)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/how-does-one-query-the-database/#post-8430811)
 * Just updating to add that I would ideally like to group it by user_id.
 *  Thread Starter [adamglatt](https://wordpress.org/support/users/adamglatt/)
 * (@adamglatt)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/how-does-one-query-the-database/#post-8430876)
 * User Error: I was trying to use the wrong table. (values instead of submits)
 * For anyone else wondering, I re-read [this page](http://cfdbplugin.com/?page_id=239)
   and was able to successfully query the data I wanted.
 * Thanks again for a great plugin!
    -  This reply was modified 9 years, 6 months ago by [adamglatt](https://wordpress.org/support/users/adamglatt/).

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

The topic ‘How does one query the database?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-to-database-extension_ffffff.
   svg)
 * [Contact Form DB](https://wordpress.org/plugins/contact-form-7-to-database-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-to-database-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [adamglatt](https://wordpress.org/support/users/adamglatt/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/how-does-one-query-the-database/#post-8430876)
 * Status: resolved