Sub Query in Query Builder

I’ve built a query using Query Builder and now I realize I needs it to be a Sub Query. Is there a way to make the original query a sub query without having to recreate the whole thing from scratch?

It depends on where your subqury needs to go. To build a where condition subquery use the where condition editor. There is a subquery button. You can copy and paste the first query in the subquery and then go back and edit the first one. This will bring up a child Query Builder.

Debbie

Thanks Debby! That worked beautifully!

You can also make your entire query a subquery (Demote the top query, or move all queries and subqueries down a level) in the query builder by using the Project Manager. Just save the query to the Project Manager and drag it into a new Query builder and it’s a subquery. Detailed instructions below.

I like this way of doing it more because the visualizer doesn’t always work for me especially with a lot of complex joins or calculated fields I tend to have to re-do half my work. This approach should work for toad data point 2.7 and newer:

  • Save your query but leave it open in the builder.
  • Right-click on the query builder tab (where your query name is) and select “add file to project manager”
  • Open the project manager (Bottom left, it’s the tab next to the object explorer tab where you choose tables from databases) You can also select it from “View” at the top.
  • there will be a bunch of sample projects and sample folders etc. You’ll have to sift through them to find your query name.
  • Open a new blank query builder tab using the “build” button at the top.
  • Drag your query name from where it is in the project manager into the new blank query builder pane and let go.
  • This should have created a new untitled query with your query as a subquery. You might need to click the top query in the queries pane to see it.