我正在使用 Mysql,但我很难从 SELECT 查询中获取结果。我有 2 张桌子。第一个表硬件,第二个表softwares_name_cache:
desc hardware;
+----------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| DEVICEID | varchar(255) | NO | PRI | NULL | |
| NAME | varchar(255) | YES | MUL | NULL | |
| WORKGROUP | varchar(255) | YES | MUL | NULL | |
| USERDOMAIN | varchar(255) | YES | | NULL | |
| OSNAME | varchar(255) | YES | MUL | NULL | |
| OSVERSION | varchar(255) | YES | | NULL | |
| OSCOMMENTS | varchar(255) | YES | | NULL | |
| PROCESSORT | varchar(255) | YES | | NULL | |
| PROCESSORS | int(11) | YES | | 0 | |
| PROCESSORN | smallint(6) | YES | | NULL | |
| MEMORY | int(11) | YES | MUL | NULL | |
| SWAP | int(11) | YES | | NULL | |
+----------------+---------------------+------+-----+---------+----------------+
desc softwares_name_cache;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| NAME | varchar(255) | YES | UNI | NULL | |
+-------+--------------+------+-----+---------+----------------+
我正在尝试获取每个 SQL 服务器的处理器数量,因此我需要从表硬件(sum(hardware.PROCESSORN)
中加入条件,并从表 softwares_name_cache 中加入条件。 (OSNAME LIKE '%Server%')
(softwares_name_cache where name like '%Microsoft SQL Server 20%')