The Query Editor is just for you to debug MQL queries in an interactive manner. When your own program needs to query Freebase, then it can simply dispatch an HTTP GET request to the mqlread service at http://www.freebase.com/api/service/mqlread. For example, an HTTP GET to the following URL will retrieve the result of the query we've been discussing (you can just click on the link here):
The HTTP GET response will be a JSON serialization, like so
{ "code": "/api/status/ok", "result": { "/location/location/containedby": [ "New York", "United States" ], "/location/place_with_neighborhoods/neighborhoods": [ "Arrochar", "Annadale", "Arden Heights", ... ], "guid": "#9202a8c04000641f80000000002f8906", "id": "/en/new_york", "name": "New York City" }, "status": "200 OK", "transaction_id": "cache;cache01.p01.sjc1:8101;2009-07-02T20:52:33Z;0009" }
which you can parse out using whatever means your program can use to parse JSON. Note that the actual result you want is wrapped within a response envelope that contains information such as the success code of the query.
It is worth noting that the mqlread web service also supports JSONP through a callback URL parameter so that you can call it also if your web application was a client-side Ajax application that was running in another domain.
See the list of libraries to find a library for the programming language of your choice that can help you connect your applications to Freebase.