Querying All Hardware Inventory Items

All of the database query examples are specific to MySQL. If the underlying database is not MySQL, the query will be different.

To extract all active hardware inventory items stored in the Demo Inventory Management System database, use the following query. (Enter the entire MySQL command syntax on the same line.)

mysql>SELECT dev.name, dev.model, hw.name, hw.version, hw.part_number, hw.serial_number, hw.description, hw.chassis_id, hw.module, hw.submodule, hw.subsubmodule, hw.last_scanned, hw.created_onFROM demo.hardware_inventory hw     INNER JOIN demo.devices dev ON hw.device_id = dev.id WHERE hw.deleted_on = 0 AND dev.deleted_on = 0;

When an item is no longer active, the deleted_on field is updated with the time the entry was removed.

You can make an entry inactive in one of two ways:

The last_scanned field stores the timestamp of the item (row) when it was last updated and processed by the Inventory Management System, regardless of whether the item (row) itself was modified.

The created_on field stores the timestamp of the item (row) when it was first scanned and processed by the Inventory Management System. If this item is removed from one chassis and moved to another, the created_on timestamp will remain the same.