Building WHERE or HAVING Clause

When retrieving data, you may want to set up a filtering expression or relation between tables. You can do it using WHERE and HAVING clauses. Refer to SQL manual to learn what’s different in these sections. In dbForge Studio visual interface for WHERE and HAVING clauses is the same.

In the tabbed editor conditions are displayed as a tree with condition and group nodes. A group consists of several conditions or subgroups, united with a logical operator. You can change a group logical operator by clicking it and selecting another one from the menu. To navigate between conditions and groups, use the UP ARROW and DOWN ARROW keys. Use the LEFT ARROW and RIGHT ARROW keys to navigate between criteria operator and operands.

To create a new group, do one of the following:

  • Click the upper-level group operator and choose Add Group on the appeared menu.
  • Press CTRL+PLUS SIGN.

Building WHERE and HAVING Clause

To create a new condition, do the following:

  1. Navigate to the group you want to enhance and click the button or press INSERT or PLUS SIGN key. Alternatively, click the upper-level group operator and choose Add Condition on the appeared menu.
  2. Click the condition column and select the column you need on the appeared menu.
  3. Click the condition criteria operator and select the criteria operator you want from the list.
  4. If the condition operator requires operand value(s), specify it (them).

To remove a condition, click the condition button or navigate to condition and press DELETE or MINUS SIGN key. To remove a group click its logical operator and choose Remove Group on the appeared menu or navigate to the group and press DELETE or MINUS SIGN key.

You also can copy, cut, and paste conditions and groups with CTRL+C, CTRL+X, and CTRL+V keys.

The following clause is generated according to the sample image:

WHERE
  Product.Color = 'silver' AND
  ProductCategory.Name >= 'components'