TableCore

SQL to MongoDB

MongoDB Compass SQL query: what works, what does not

Compass has no SQL box. What its query bar takes instead, what the AI query bar costs you, and where MongoDB's official SQL access actually lives.

TableCore Team7 min read

The short answer

MongoDB Compass has no SQL box. There is no tab, no toggle and no preference that turns the query bar into a SELECT prompt. Compass is a client for MongoDB's own query language, and that is what its query bar accepts.

That is not the end of the story — there are three things people mean when they search for this, and two of them have real answers. It is worth separating them before you spend an afternoon looking for a menu item that does not exist.

What the Compass query bar actually takes

The Filter field takes a MongoDB filter document: JSON, with MongoDB operators. It is the equivalent of a SQL WHERE clause and nothing else. The other fields of the query bar — Project, Sort, Skip, Limit, Collation — cover the rest of what a simple SELECT says:

SQLCompass query bar
WHERE author = 'Joe Bloggs'Filter: { author: { $eq: "Joe Bloggs" } }
SELECT title, authorProject: { title: 1, author: 1 }
ORDER BY published DESCSort: { published: -1 }
LIMIT 20 OFFSET 40Limit: 20, Skip: 40

So a single-collection query with a filter and a sort maps across mechanically, field by field. What has no home in that bar is everything that makes SQL worth writing: a JOIN, a GROUP BY, an aggregate over the matched rows. Those live in the Aggregations tab, where you build a pipeline one stage at a time, each stage a JSON document, with a preview of the result after each.

The aggregation builder is a good tool. It is also, unmistakably, a tool for someone who has decided to learn the pipeline. If you know the SQL you want and you are trying to reach it stage by stage, you are translating in your head and typing the answer — which is the work you were hoping to avoid.

The AI query bar, and what it costs you

Recent Compass versions include a natural-language query bar, and MongoDB's own documentation notes that you can paste SQL, or a query lifted from application code, into it. So there is a route from a SELECT to something runnable inside Compass.

Read the terms on it before you rely on it:

  • It sends your prompt and your schema off the machine. MongoDB documents that the text of the prompt and details about your MongoDB schemas go to Microsoft and OpenAI for processing. Not the documents themselves, but the shape of your data and the question you asked. In plenty of organisations that decides the matter on its own.
  • It is generative and explicitly experimental. MongoDB's documentation says it may give inaccurate results. An inaccurate translation of a SELECT is not an error message — it is a different query that returns rows, and you find out it was wrong later, or never.
  • You cannot predict what it will produce. MongoDB warns that the complexity of the returned query is hard to anticipate, and suggests adjusting the query bar's max-time option so a generated pipeline does not run away with itself.

For exploring an unfamiliar collection, that is a reasonable trade. For a query whose answer you are going to act on, "probably equivalent" is a weaker guarantee than most people are looking for when they search for SQL support.

The official SQL path is not Compass at all

MongoDB does offer SQL access, but through a different product line aimed at business-intelligence tools rather than at Compass users.

The MongoDB Connector for BI presented a MongoDB deployment over the MySQL wire protocol, so Tableau, Power BI and similar tools could query it with SQL over ODBC or JDBC. It is on the way out: the Atlas BI Connector was announced for deprecation in June 2025, and MongoDB's guidance is to move to the newer MongoDB SQL Interface for new projects.

Both share the same shape, and it is the shape that matters here:

  • They are drivers and connectors for BI tools, not an interactive query editor. You point Tableau at them; you do not sit and iterate in them.
  • They need a relational view of the data — a schema mapping that flattens documents into tables and columns before any SQL can be written against them.
  • They are tied to particular deployments: the SQL Interface targets Atlas and Enterprise Advanced, not any MongoDB you happen to have running.

If your actual goal is "connect Power BI to MongoDB", this is your answer and Compass was never involved. If your goal is "I want to write SELECT while I work", it is a heavy amount of infrastructure to stand up for a query bar.

Which of the three questions you are asking

It is worth being explicit, because the three have genuinely different answers:

  1. "Can I type SQL into Compass and run it?" No. The query bar takes a filter document; complex queries go to the aggregation builder.
  2. "Can I get Compass to convert my SQL?" Approximately, via the AI query bar, at the cost of sending your prompt and schema to a third party and accepting an experimental, unverified translation.
  3. "Can I query MongoDB with SQL at all?" Yes — through the BI connector line for BI tools, or through a client that translates SQL into MongoDB queries directly.

The fourth option: a client built around the translation

TableCore is the third answer above in the form of a desktop client. You write SQL, it generates the MongoDB command, it shows you that command rather than hiding it, and it runs it against your database. No schema mapping to configure, no connector to deploy, and nothing about your query leaves the machine.

The honest boundaries, since this article has been strict with everyone else's: TableCore supports a documented subset of SQL and refuses a query outside it rather than answering something approximate; it is Windows-only today; and it is not an administration tool — Compass does index management, schema analysis and server metrics, and TableCore does none of those. Running both is the ordinary arrangement, and TableCore vs MongoDB Compass sets out where each one wins.

You can test the translation before installing anything. The browser-based SQL to MongoDB converter takes a SELECT and shows the MongoDB command it becomes, entirely in your browser, with no account and no database connection. For the wider question behind the search, how to query MongoDB with SQL compares every approach; if it is joins you are missing in the query bar, the $lookup guide covers those.

Try it yourself

Paste your SQL into TableCore and run it against MongoDB.

The desktop app converts your SQL into a real MongoDB query, shows the results as typed BSON and keeps both views in sync.

The download page reflects the current public release catalog. macOS and Linux are planned.