Sorry bradgrafelman, I realized after I posted that I used the term 'query string' which was ambiguous. By query string, I did mean a string for a DB query and not the URL query string.
Matt - thanks 🙂 I was trying to do it all in one step and this method never occurred to me. I should be able to get it now.