Building a Query

From RapidSQL
Jump to: navigation, search

Go Up to Using Query Builder

Query Builder lets you build SELECT, INSERT, UPDATE, SELECT, and CREATE VIEW statements, which you can run separately or simultaneously, depending on your needs.

To build a Query, do the following:

Note: You can start Query Builder directly from a table or view which automatically selects the database which contains that table or view.

Query Builder lets you build queries that include both tables and views in the SQL Diagram Pane for SELECT and CREATE VIEW statements. For the INSERT, UPDATE, and DELETE statements, use one or the other object, but you cannot use both.

Once you make your selections, you can edit, restructure, and streamline your query. Query Builder offers many options for streamlining your queries.

Building a SELECT Statement

Query Builder lets you construct and execute simple-to-complex SELECT statements using data from any table or view. You can also create and edit joins for SELECT statements. Query Builder can check your query and warn you if there are syntax errors with the Syntax Checker.

To build a SELECT statement, do the following:

  1. On the Tools menu, click Query Builder.
    The Query Builder opens.
  2. In the statement drop-down list, click SELECT.
  3. In the Table Tree Pane, select target table(s) or view(s) and move them to the SQL Diagram Pane.
  4. In the target table or view, click target column(s), or click Select Star to select every column.
  5. To check syntax, click Check.
  6. To copy the statement, click Copy.
  7. To execute the statement, click Execute.

Copying a SELECT Statement from the SQL Statement Pane

To copy any part of a statement from the SQL Statement Pane, do the following:

  1. Open Query Builder, then begin a new SELECT statement.
    OR
    Open an existing SELECT statement.
  2. In the SQL Statement Pane, select all, or the target portion of the statement.
  3. On the Query Builder tool bar, click Copy.
    OR
    In the SQL Statement Pane, right-click, and then click Copy.
    Query Builder makes the target statement portion available on the clipboard.

Building an INSERT Statement

Query Builder lets you construct and execute simple-to-complex INSERT statements using data from any table. To execute an INSERT statement, copy it to an ISQL Editor. You can also copy the statement to the clipboard for later use in the ISQL Editor.

Query Builder also lets you save your statement at any time so that you can open it later for editing or execution. For details, see Saving and Reopening Queries.

Building an INSERT Statement

To build an INSERT Statement, do the following:

  1. On the Tools menu, click Query Builder.
    The Query Builder opens.
  2. In the statement drop-down list, click INSERT.
  3. In the Table Tree Pane, select target table, and move it to the SQL Diagram Pane.
  4. In the target table, click target column(s).

Copying an INSERT Statement from the SQL Statement Pane

To copy any part of a statement from the SQL Statement Pane, do the following:

  1. Open Query Builder, then begin a new INSERT statement.
    OR
    Open an existing INSERT statement.
  2. In the SQL Statement Pane, select all, or the target portion of the statement.
  3. On the Query Builder tool bar, click Copy.
    OR
    In the SQL Statement Pane, right-click, and then click Copy.
    Query Builder makes the target statement portion available on the clipboard.

Building an UPDATE Statement

Query Builder lets you construct and execute simple-to-complex UPDATE statement using data from any table. To execute an UPDATE statement, copy it to an ISQL Editor. You can also copy the statement to the clipboard for later use in the ISQL Editor.

Query Builder also lets you save your statement at any time so that you can open it later for editing or execution. For details, see Saving and Reopening Queries.

Building an UPDATE Statement

To build an UPDATE statement, do the following:

  1. On the Tools menu, click Query Builder.
    The Query Builder opens.
  2. In the statement drop-down list, click UPDATE.
  3. In the Table Tree Pane, select target table and move it to the SQL Diagram Pane.
  4. In the target table, click target column(s).

Copying an UPDATE Statement from the SQL Statement Pane

To copy any part of a statement from the SQL Statement Pane, do the following:

  1. Open Query Builder, then begin a new UPDATE statement.
    OR
    Open an existing UPDATE statement.
  2. In the SQL Statement Pane, select all, or the target portion of the statement.
  3. On the Query Builder tool bar, click Copy.
    OR
    In the SQL Statement Pane, right-click, and then click Copy.
    Query Builder makes the target statement portion available on the clipboard.

Building a DELETE Statement

Query Builder lets you construct DELETE statements using data from any table. Query Builder displays a Confirmation Option Message box when you create a DELETE statement. You can set the Statement Properties dialog box to display or hide this message when creating a DELETE statement. For details, see Statement Properties.

To execute a DELETE statement, copy it to an ISQL Editor. You can also copy the statement to the clipboard for later use in the ISQL Editor.

Query Builder also lets you save your statement at any time so that you can open it later for editing or execution. For details, see Saving and Reopening Queries.

Building a DELETE Statement

To build a DELETE statement, do the following:

1 On the Tools menu, click Query Builder.
The Query Builder opens.
2 In the statement drop-down list, click DELETE.
3 In the Table Tree Pane, select target table, and move it to the SQL Diagram Pane.

Copying a DELETE Statement from the SQL Statement Pane

To copy any part of a statement from the SQL Statement Pane, do the following:

  1. Open Query Builder, then begin a new DELETE statement.
    OR
    Open an existing DELETE statement.
  2. In the SQL Statement Pane, select all, or the target portion of the statement.
  3. On the Query Builder tool bar, click Copy.
    OR
    In the SQL Statement Pane, right-click, and then click Copy.
    Query Builder makes the target statement portion available on the clipboard.

Building a CREATE VIEW Statement

Query Builder lets you construct and execute simple-to-complex CREATE VIEW statements using data from any table or view. You can also copy the statement to the clipboard for later use in the ISQL Editor.

Query Builder also lets you save your statement at any time so that you can open it later for editing or execution. For details, see Saving and Reopening Queries.

To build a CREATE VIEW statement, do the following:

  1. On the Tools menu, click Query Builder.
    The Query Builder opens.
  2. In the statement drop-down list, click CREATE VIEW.
  3. In the Table Tree Pane, select target table or view and move it to the SQL Diagram Pane.
    Note: Query Builder supports multiple tables and views in a CREATE VIEW statement.
  4. In the target table or view, click the target column(s).
  5. To check syntax, click Check.
  6. To copy the statement, click Copy.
  7. To execute the CREATE VIEW Statement, click the SQL Statement Pane, and then press any key.
    Query Builder opens the Edit SQL dialog box.
  8. Click OK.
    Caution: If you have used this method previously, and you selected the Please do not show me this dialog again check box, on the Edit SQL dialog box, Query Builder does not display the Edit SQL dialog box. It pastes your statement directly to the ISQL Editor.
    The ISQL Editor opens.
  9. In the ISQL Editor, on the line, CREATE VIEW NAME AS, replace the word NAME with a name for your view.
  10. On the tool bar, click Execute.
    The CREATE VIEW query executes.
  11. To close the Editor, click Close.
    The ISQL Editor save message opens.
  12. Click No.
  13. To add the view to the table tree, on the Query Builder menu, click Refresh.
    Query Builder adds the view to the Table Tree Pane.

Copying a CREATE VIEW Statement from the SQL Statement Pane

To copy any part of a statement from the SQL Statement Pane, do the following:

  1. Open Query Builder, then begin a new CREATE VIEW statement.
    OR
    Open an existing CREATE VIEW statement.
  2. In the SQL Statement Pane, select all, or the target portion of the statement.
  3. On the Query Builder tool bar, click Copy.
    OR
    In the SQL Statement Pane, right-click, and then click Copy.
    Query Builder makes the target statement portion available on the clipboard.

Topics

Personal tools