Title: mySQL Query issues
Last modified: August 24, 2016

---

# mySQL Query issues

 *  Resolved [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [11 years ago](https://wordpress.org/support/topic/mysql-query-issues/)
 * Michael,
    Fantastic plugin with many great features!!
 * My application is passing two variables via an URL that identify an uniqueID 
   and provide a value for an updated field. I’ve got my variable passing working
   but am struggling with the sql query and subsequent update.
 * I started by simply using the generated query to make sure my sql is working 
   and it does work. The trouble comes when I add the SQL query outside the generated
   query. Then nothing is returned. My code looks like:
 *     ```
       SELECT * FROM
            <generated query goes here>
       WHERE 'UniqueID' = $uniqueID
       ```
   
 * UniqueID is the DB field name and $uniqueID is the passed variable.
 * Is there anything special that has to go in the query outside the generated query?
 * Any code tidbits on updating the record I do finally SELECT?
 * [https://wordpress.org/plugins/contact-form-7-to-database-extension/](https://wordpress.org/plugins/contact-form-7-to-database-extension/)

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

 *  Thread Starter [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [11 years ago](https://wordpress.org/support/topic/mysql-query-issues/#post-6178481)
 * I believe my issue is that I am using the $wpdb->get_results to perform the sql
   query so it can not handle nested selects. So I made this change:
 *     ```
       $dbarray = $wpdb->get_results("Select... this is the generated query)
       $query = $wpdb->get_results ("Select * FROM $dbarray WHERE <code>UniqueDB</code> = $uniqueID");
       ```
   
 * The $dbarray contains the entire DB but $query is null. I do know that there 
   is a record that matches the WHERE condition. I have also tried other fields 
   in the database but nothing is ever retrieved.
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years ago](https://wordpress.org/support/topic/mysql-query-issues/#post-6178555)
 * I recommend against access the data via SQL directly. Use the API instead.
 * [http://cfdbplugin.com/?page_id=367](http://cfdbplugin.com/?page_id=367)
 *  Thread Starter [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [11 years ago](https://wordpress.org/support/topic/mysql-query-issues/#post-6178559)
 * Michael,
    Thanks for the advice. Any advice on updating the contact form data
   from PHP?
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years ago](https://wordpress.org/support/topic/mysql-query-issues/#post-6178561)
 * No APIs specifically for that.
 *  Thread Starter [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [11 years ago](https://wordpress.org/support/topic/mysql-query-issues/#post-6178612)
 * Addressed the issue by direct access to the $wpdb.

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

The topic ‘mySQL Query issues’ 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/)

 * 5 replies
 * 2 participants
 * Last reply from: [andywt](https://wordpress.org/support/users/andywt/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/mysql-query-issues/#post-6178612)
 * Status: resolved