• Resolved andywt

    (@andywt)


    I am struggling trying to get a nested query to work. I am using a plugin, CFDB, that stores its data in a way that can be retrieved using a pivot query. What I am trying to do is wrap a query on the results of the pivot query and subsequently update the data. I’ve tried a variety of methods but had no success other than getting the pivot query to deliver an array.

    Here is my code:

    $queryresults = $wpdb->get_results("Select * FROM
    							(SELECT <code>submit_time</code> AS 'Submitted',
    								max(if(<code>field_name</code>='Route', <code>field_value</code>, null )) AS 'Route',
     								max(if(<code>field_name</code>='Contact Information', <code>field_value</code>, null )) AS 'Contact Information',
     								max(if(<code>field_name</code>='UniqueID', <code>field_value</code>, null )) AS 'UniqueID',
     							GROUP_CONCAT(if(<code>file</code> is null or length(<code>file</code>) = 0, null, <code>field_name</code>)) AS 'fields_with_file'
     							FROM <code>fg_cf7dbplugin_submits</code>
    							WHERE <code>form_name</code> = '2015 Flag Database Missing Flag'
    							GROUP BY <code>submit_time</code>
    							ORDER BY <code>uniqueID</code> ASC
    							LIMIT 0,5000)");
    		foreach ( $queryresults as $queryresults ) {
    			echo "<pre>"; print_r( $queryresults ); echo "<pre>";
    	}

    Nothing is ever returned. If I do a query with the inner SELECT only, the array is returned, so I’m thinking my nesting is causing the issue.

    Thanks for your help.

Viewing 1 replies (of 1 total)
  • Thread Starter andywt

    (@andywt)

    Solved this by accessing the $wpdb directly.

Viewing 1 replies (of 1 total)

The topic ‘Nested Query with get->results’ is closed to new replies.