Return result of query as variable

Post your full code again.