in reply to where clause

Have a look at Text-Query-SQL, it might be what you need.
Hope this helps ;-)