drop table if exists descriptors;
Descriptors is just a lookup table storing the meaning of `idx` values eg for reports. It'll have 7 rows...
create table descriptors(idx tinyint, description char(32));
insert into descriptors values
(1, 'employee with ID' ),
(2, 'age' ),
(3, 'rank' ),
(4, 'salary range' ),
(5, 'projects managed' ),
(6, 'projects finished this year' ),
(7, 'project overdue days');
Your result tables will have 6 or 7 times as many rows as they do now, millions of rows, which is not a lot, and they will query hundreds of times faster without those nonsensical loops.
You're going to need to read about database design, eg
http://www.artfulsoftware.com/dbdesignbasics.html