Added a very ugly way of using nested queries. I have only tested it for my scenario and the code needs cleaning up. But it seems to work. If you need nested queries, please check them out.