The need to transform queries between heterogeneous databases arises in many circumstances, including query transformation between a global and a local query. This paper describes a query mediation approach to the interoperability of heterogeneous databases. We develop a query mediation architecture that facilitates automated query transformation, which is applicable in many circumstances, such as query transformation in a federated database environment. Different application languages are transformed into intermediate representations that can be processed by the query mediator. The main characteristic of our system is that the query transformation agent, which acts as a mediator, is used to support automated query transformation which protects users from the troublesome task of semantic and representational discrepancies. Two query languages, ODMG-OQL and SQL, have been used to investigate the query mediation architecture.