How to build WHERE or HAVING clauses

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 from 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 FilterGreyAdd or press INSERT or PLUS SIGN key. Alternatively, click the upper-level group operator and choose Add Condition from the appeared menu.
  2. Click the condition column and select the column you need from 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 FilterGreyDel or navigate to condition and press the DELETE or MINUS SIGN key. To remove a group click its logical operator and choose Remove Group from 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.

Where tab

The following clause is generated according to the sample image:

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

Download dbForge Studio for SQL Server and try it absolutely free for 30 days!

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?