[This is preliminary documentation and subject to change.]
A SELECT statement returns a result set. If a SELECT statement specifies a class with many derived classes as the target class, instances of all of the derived classes are automatically included in the result set. To override this default behavior and retrieve only instances of the target class, the SELECT statement must include a WHERE clause that includes the __CLASS system property:
/* Retrieve instances of the Device class and its derived classes */
select * from Device
/* Retrieve only instances of the Device class */
select * from Device where __CLASS = "Device"
Similarly, using the __CLASS system property to test for classes derived from the target class restricts the result set to instances only of those classes:
Select * from Device where __CLASS="Modem" or __CLASS="Motherboard"
Projection operations using the SELECT statement are accomplished by explicitly listing the desired properties. The following statement shows how to retrieve only the Name and FreeSpace properties from every instance of the Win32_LogicalDisk class. Attempts to access other properties known to be in the class will fail.
Select Name, FreeSpace from Win32_LogicalDisk
In addition to the __CLASS property, there are other system properties that are automatically included in the result set regardless of whether they were specified in the WHERE clause. The following table describes the rules that govern the use of these system properties:
System property | WQL usage |
---|---|
__CLASS | Always returned with each instance whether requested or not. |
__SERVER | Only returned if the __PATH property is requested. |
__NAMESPACE | Only returned if the __PATH property is requested. |
__DERIVATION | Only returned if explicitly requested. |
__DYNASTY | Only returned if explicitly requested. |
__SUPERCLASS | Only returned if explicitly requested. |
__PATH | Causes the key property or properties to be returned along with the __SERVER and __NAMESPACE properties. |
__RELPATH | Causes the key property or properties to be returned. |