Building a SQL Query in MyEclipse
The Visual SQL Query editor available in MyEclipse can be used to easily create complex SQL queries without having to remember complex SQL syntax. Visually add tables, create joins, manage groups, expressions and order your output with easy-to-use wizards. In this tutorial, you will learn how to:
- Open the Visual SQL Query editor
- Add tables to the query and create a join
- Build an expression
- Run the SQL
Duration Time: 10 Minutes
Don't have MyEclipse? Download Now
1. Open the Visual SQL Query Editor
There are several ways to access the Visual SQL Query editor.
1.1 Opening from the SQL Editor
Right-click the SQL editor, and select Open in MyEclipse Visual SQL Query Editor. When you finish with the Visual SQL Query editor, the query you created is inserted into the SQL editor, replacing the selected query, if any.
1.2 Opening Existing SQL Files
Right-click a SQL file, and click Open With>MyEclipse Visual SQL Query Editor.
1.3 Opening from a Database Connection
Right-click a connection in the DB Browser, and select New Visual SQL Query Editor.
2. Add Tables to a Query and Create Joins
- Right-click the editor, and select
- Select a table, and click OK to use it in your query.
- Drag from one column to another to create a join between the two.
3. Build Expressions for Your Output
Build Expression from the Column drop-down.
- Choose the type of expression you want to build.
This example uses the SUM function to return the sum of the AMOUNT column in the PAYMENT table.
- Use the Groups tab to group the results by the CUSTOMERNAME column.
4. Run the Query
The image below depicts the finished query. To execute this, right-click the source view, and select Run SQL.
Results are displayed in the SQL Results view.