Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Data Tools Platform Guide
Previous Page Home Next Page


Creating a SELECT Statement

Use SQL Query Builder to create a SELECT statement to retrieve data from a database and display the results set in table format.

Prerequisites 

Connect to the data source through a connection profile.

Note: Some syntactic variations might exist between your database and the SQL syntax that SQL Query Builder supports; consequently, some SQL Query Builder features might not work with your database.
  1. Open a new or an existing SQL file, and be sure to select the connection profile Type, Name, and Database.
  2. In an appropriate place in the editor window, right-click and select Edit in SQL Query Builder.
  3. Add one or more tables to the statement.
    1. Right-click in the Tables pane and select Add Table.
    2. (Optional) Indicate a Table alias.

      You might want to use a table alias to make the table name more readable or shorten it for display/output.

  4. (Optional) If you added two or more tables, you can create a join.
  5. (Optional) Select DISTINCT if you want only one instance each of duplicated rows returned in the final result set.
  6. Specify the columns to use in the statement.
    Option Description
    Specify all columns Right-click the table in the Tables pane, and select Select All Columns.
    Specify specific columns Use either method:
    • In the Tables pane, select the check box next to the column name.
    • In the Columns tab, select the specific column from the drop-down menu.
  7. (Optional) Define other column attributes.
    1. Specify a column alias.

      You might want to use a column alias to make the column name more readable or shorten it for display/output.

    2. Deselect Output if you do not want the column values to display in the results set but want to use it for some other purpose.

      For example, you might want to order the output by customer number but you do not want the customer number to display.

    3. Change the Sort Type for each column.

      By default, columns are sorted in ascending order.

    4. Change the Sort Order.

      By default, columns are sorted in the order they appear in the Columns table.

  8. (Optional) In the Conditions tab, indicate the conditions for the statement.

    The conditions enable you to better define which columns appear in the results set. For example, you might only want to list store locations with sales greater than $10,000.

    1. Select a Column.

      Alternately, select define a condition using the Expression Builder wizard.

    2. Select an Operator.
    3. Enter a specific Value, select a column from the drop-down list, or build an expression.
    4. (Optional) Select AND or OR to specify another condition.
  9. (Optional) In the Group tab, indicate on which column you want to group results.

    For example, you might want to group the sum of all sales from each store.

  10. (Optional) To limit the output based on the specified GROUP clause, add a Group Condition.
    1. Select a Column.

      Alternately, select define a condition using the Expression Builder wizard.

    2. Select an Operator.
    3. Enter a specific Value, select a column from the drop-down list, or build an expression.
    4. (Optional) Select AND or OR to specify another condition.
  11. (Optional) To run the SQL code, in the SQL Source pane, right-click and select Run SQL.

    View the results in the SQL Results tab.

  12. Click OK to exit SQL Query Builder and to return to the SQL File Editor, where the SQL code displays in the editor window.

    Clicking Cancel results in no changes to the SQL code in the SQL File Editor. You lose any changes you made in SQL Query Builder.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire