Unfortunately I have tried this approach to no avail. I have tried it with almost every variation of syntax I can think of. It seems that no matter what I do, if I put a string ($field) in the first part of the WHERE clause it returns 'unknown column' even though it's defined before the DBMS sees the query.