File - Create - New Query

Queries in Manifold are written in a language called SQL, the same SQL language that has become overwhelmingly popular through many years of use with databases.  

 

An item in the project pane marked with a query icon is a component that contains SQL text in it.  If we double-click a query, it opens up in a  Command Window, which is a special console in Manifold that makes writing SQL queries easier.

 

To create a query:

 

  1. Right-click into the Project pane and choose Create - New Query to create a new query, or choose File - Create - New Query.
  2. Specify a name for the new query, and press Create Query.
  3. Double-click the new query to open it in the Command Window.
  4. Write a query in the upper pane, double-clicking in the templates and tables panes to save keyboarding.
  5. The query is automatically saved as we edit.  Make a copy before editing if multistep undo is desired.

 

To write a temporary query:

 

  1. Choose View - New Command Window - SQL.
  2. Write a query in the upper pane.
  3. If we want to save what we've written, we can choose Edit - Save as Query.

 

New queries created within the Command Window disappear when the Command Window is closed.   To save the query, choose Edit - Save As Query to save the query text as a query in the project.

File - Create - New Query

 

In the main menu choose File - Create - New Query or right-click an empty spot in the Project pane and choose Create - New Query.

 

Name

Name for the query.  "Query" by default.  Specify a more informative name as desired.

Create

Query

Create the new query.

Edit Query

We can write SQL in a query that creates other components.  For example, we can write a query that creates a table and a drawing.  We can also write a query that creates a new query component.  

 

The Edit Query button launch the Command Window loaded with a query that creates a new query using the given name. This is a a great way to learn how to use SQL to create queries.

Cancel

 Exit the dialog without doing anything.

 

Notes

 

Two ways to create and run queries -  In Manifold, we have two ways to write and to use SQL:

 

 

 

See Also

Tables

 

Queries

 

Editing Queries, Scripts and Comments

 

View - New Command Window

 

Command Window

 

Command Window - Query Builder

 

SQL

 

Editable Results Tables

 

Example: Create a Drawing from a Query - Everybody knows we can create a drawing from a table, but we can also create a drawing from a query.  When the query reports different results the drawing changes too.   This example show step by step how to create a query and then how to create a drawing from that query.   We show how to command Manifold to write a query for us that grabs a selection, and then how to create a drawing based on that new query.   This example duplicates the Drawings from Queries video using the Mexico_queries.mxb sample project that may be downloaded from the Examples page on the Manifold web site.  

 

Example: Create and Run a Query -  See how the different parts of a command window operate when creating and running SQL queries.   Includes use of the Log tab as well as the ?expression and !fullfetch commands.

 

Example: Export the Results of a Query - How to export the results table of a query for use in other applications.

 

Example: Automatically Generating CREATE Queries - How to use the Command window to automatically generate SQL in the form of CREATE queries that create a desired component.

 

SQL Example: Learn SQL from Edit Query - Merging Areas - We learn how to write an SQL query that does a Merge : area (dissolve) operation by cutting and pasting from what the Edit Query button automatically generates.

 

Example: Transform Templates, Expressions and Queries - We learn to use a function by clicking on a template in the Transform pane, seeing what it does in a preview, looking at the query Manifold creates and then trying out the function in the Expression tab.