I have a table generated by a WordPress plugin that collects form submission data. The structure of the table is not ideal - has "submission_time" as primary key and what I want to be fields (firstName, lastName, email, phone, affiliation, etc.) are actually field values in the field called "field_value". See images...

Click image for larger version. 

Name:	table2.jpg 
Views:	2 
Size:	726.8 KB 
ID:	15989Click image for larger version. 

Name:	table1.jpg 
Views:	1 
Size:	197.2 KB 
ID:	15990

I also have another table which I want to append data and booleans on to the data from the first table based on the submit_time field value. See image below...

Click image for larger version. 

Name:	join-table.jpg 
Views:	1 
Size:	216.0 KB 
ID:	15991

In the image below, the data in the rows is taken from the WordPress plugin table I'll call it table 1) with submit_time as a primary key while the Sent column is taken from another table (call it table 2) with submit_time as a foreign key. I loop through the data in table 1 and display it with a foreach loop for each row in the table, but I need to see if the boolean "is_sent" is marked 1 or 0 in table 2 based on the submit time and display a checkmark if it is marked 1 and an empty checkbox if it is marked 0.

Click image for larger version. 

Name:	my-app.jpg 
Views:	1 
Size:	488.7 KB 
ID:	15992

I'm not sure how to do the JOIN in order to do this. Any help you can give is much appreciated!

Here is my SQL for getting the data from table 1 and displaying it in the table rows if you want to see this..
"SELECT `submit_time` AS 'Submitted',
                max(if(`field_name`='firstName', `field_value`, null )) AS 'firstName',
                max(if(`field_name`='lastName', `field_value`, null )) AS 'lastName',
                max(if(`field_name`='email', `field_value`, null )) AS 'email',
                max(if(`field_name`='phone', `field_value`, null )) AS 'phone',
                max(if(`field_name`='affiliation', `field_value`, null )) AS 'affiliation',
                max(if(`field_name`='interest', `field_value`, null )) AS 'interest',
                max(if(`field_name`='productSheets', `field_value`, null )) AS 'productSheets',
                max(if(`field_name`='referredBy', `field_value`, null )) AS 'referredBy',
                max(if(`field_name`='comments', `field_value`, null )) AS 'comments',
                GROUP_CONCAT(if(`file` is null or length(`file`) = 0, null, `field_name`)) AS 'fields_with_file'
                FROM `wp_cf7dbplugin_submits` 
                WHERE `submit_time` = ".$this->uri->segment(3)." AND `form_name` = 'PSRequestForm'
                GROUP BY `submit_time` 
                ORDER BY `submit_time` DESC
                LIMIT 0,100"