Fix for multiple results from subquery

If the table name is the same between multiple schemas, multiple
results get returned from the subquery which causes the query to fail.
Merge pull request #7 from Kwal/master

Fix for multiple results from subquery