You need to pivot these key value pairs into columns, unfortunately, MySQL doesn't have a pivot table operator. But you can use the CASE
expression to do so:
SELECT
t1.id,
MAX(CASE WHEN t2.key = 'first_name' THEN value END) AS first_name,
MAX(CASE WHEN t2.key = 'last_name' THEN value END) AS last_name,
t1.email
FROM table1 AS t1
INNER JOIN table2 AS t2 ON t1.id = t2.id
GROUP BY t1.id,
t1.email;
SQL Fiddle Demo
If you want to do this dynamically and not to write all these values manually you have to use dynamic SQL to do this:
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT CONCAT('MAX(IF(t2.key = ''',
t2.key, ''', t2.value, 0)) AS ', '''', t2.key, '''')
) INTO @sql
FROM table2 AS t2;
SET @sql = CONCAT('
SELECT
t1.id,', @sql, ',
t1.email
FROM table1 AS t1
INNER JOIN table2 AS t2 ON t1.id = t2.id
GROUP BY t1.id, t1.email');
prepare stmt
FROM @sql;
execute stmt;