The Query Editor is a tool that helps you build SELECT statements. You can create SQL queries in the Query Editor, or you can import queries and edit them. When you have finished your query, click OK to export it back into Sybase Central or Interactive SQL for processing.
The Query Editor provides a series of tabs that guide you through the components of a SQL query, most of which are optional. The tabs are presented in the order that SQL queries are usually built:
Tab | Description |
---|---|
Tables tab | Use this tab to specify the tables in your query. |
Joins tab | Use this tab to specify a join strategy for combining the data in the tables. If you include more than one table in your query, you should specify a join strategy for combining the data in the tables. If you do not specify a join strategy for tables you added in the Tables tab, the Query Editor suggests one; if there is a foreign key relationship between the tables, it generates a join condition based on that relationship, or it suggests a cross product. When you import queries, the Query Editor accepts exactly the join strategy that you specified (and an unspecified JOIN is not defaulted to KEY JOIN, as it would be otherwise in SQL Anywhere). |
Columns tab | Use this tab to specify the columns in your result set. If you do not specify columns, all columns appear. |
INTO tab | Use this tab if you want to assign results to variables. |
WHERE tab | Use this tab if you want to specify conditions for restricting the rows in your result set. |
GROUP BY tab | Use this tab if you want to group rows in the result set. |
HAVING tab | Use this tab to restrict the rows in your result set based on group values. |
ORDER BY tab | Use this tab if you want to sort the rows. |
The Query Editor also contains the following tools:
Window | Description |
---|---|
Expression Editor | Use the Expression Editor to build search conditions or define computed columns. |
Derived table or subquery window | Use this window, which is nearly identical to the main Query Editor, to create derived tables and subqueries. |
Each component of the Query Editor has context-sensitive online help that describes how to use the tab, and provides links into the SQL Anywhere documentation that explains relevant concepts and usage. See Query Editor.
To open the Query Editor, open Interactive SQL, connect to a database, and click Tools » Edit Query. If you have SQL code selected in Interactive SQL, the selected code is automatically imported into the Query Editor.
When you finish creating a query in the Query Editor, click OK to write the query to the Interactive SQL Statements pane.
You do not need to use SQL code to create queries with the Query Editor. However, you can use SQL with the Query Editor in the following ways:
You can create a query in the SQL Statements pane in Interactive SQL, and import it into the Query Editor by highlighting the code before you open the editor.
At any time while using the Query Editor, you can click SQL at the bottom of the window to see the SQL code for the query you are building. You can directly edit the code, and the fields are automatically updated in the Query Editor user interface.
You can configure the Editor from Interactive SQL or Sybase Central so that the SQL is fully formed, meaning that all table and column names fully qualified and names are quoted. This extra formatting is not normally necessary, but it ensures that the SQL works in all situations. You can also choose to get a list of tables on startup.
The Query Editor builds SQL Anywhere SELECT statements. It is not designed to create views, although you can create them in Interactive SQL and reference them in the Query Editor. Nor was it designed to create update statements or other non-SELECT SQL statements. It creates a single SELECT statement, so it does not build unions or intersects of SELECT statements. In addition, the Query Editor does not support Transact-SQL syntax.
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |