You know what a join in SQL is?
This is a very classic INNER JOIN and is normally handled by one query:
I don't know exaclty the naming of your table, but with a little editing this should to it.
And of course you have to watch your queries if they're too big. A possibility is, only to query the subset you currently need, if you can't determine this with a given value like the date (so you can select values on a daily basis) you can do this with the LIMIT statement of MySQL (if you're using MySQL, other system have other ways to to this).