WQL SELECT Statement

[This is preliminary documentation and subject to change.]

The WQL SELECT statement is much like the standard SQL statement for retrieving information. Where the SQL SELECT statement is typically used in the database environment to retrieve particular columns from tables, the WQL SELECT statement is used in WBEM to retrieve properties from classes. The supported scope also differs from SQL. While SQL supports queries across multiple tables, WQL supports only single class queries.

The most basic SELECT statement uses the following syntax:

select * from <ClassName>

This statement returns an instance that contains all of the properties for the specified class and its derived classes. To request particular properties, replace the asterisk with a property list delimited by commas:

select <property_1, property_2,   property_N> from <ClassName>

Using normal SQL rules, subsets of class instances can be selected by specifying a query constrained by a WHERE clause. The WHERE clause is limited to the following forms:

property operator constant

--orconstant operator property

The constant must be of the correct type for the property and the operator must be one of the following values:

String comparisons using = and != are always case-insensitive.

When the WHERE clause contains more than one property, operator, and constant, each group must be joined with AND, OR, or NOT.

The following examples show valid SELECT statements. The first example retrieves all of the properties of the Win32_LogicalDisk class belonging to instances that have their Name property set to either "C:" or "D:":

select * from Win32_LogicalDisk 
    where Name = "C:" or Name = "D:"
 

The second example retrieves disks named "C:" or "D:" only if they have a certain amount of free space remaining and have NTFS file systems:

select * from Win32_LogicalDisk 
    where (Name = "C:" or Name = "D:") 
    and   FreeSpace > 2000000 
    and   FileSystem = "NTFS"
 

Note  In addition to queries involving multiple classes, the following features of the SQL SELECT statement are not supported by WQL: