我有以下MySQL查询。
Scanner scannerLines = new Scanner(file)) {
int lineNum = 0;
while (scannerLines.hasNextLine()) {
String line = scannerLines.nextLine();
if (line.contains(" alle ")) {
String nextLine = scannerLines.nextLine();
Pattern pattern =
Pattern.compile("\\s\\d\\d\\s");
Matcher matcher =
pattern.matcher(nextLine);
while(matcher.find()){
System.out.println(matcher.group());
}
}
}
输出在这里:
SELECT h.hostname
, c.name
, d.cim_item
, t.datastatus
, DATEDIFF(NOW(), s.time)
FROM plugin_sw_vmware_healthmon_hosts h
JOIN
( SELECT clientid
, locationid
, hostname
, MAX(scantime) Time
FROM labtech.plugin_sw_vmware_healthmon_scans
GROUP
BY clientid
, locationid
, hostname
) s
ON h.clientid = s.clientid
AND h.locationid = s.locationid
AND h.hostname = s.hostname
JOIN clients c
ON c.clientid = h.clientid
JOIN plugin_sw_vmware_healthmon_cimdata d
ON d.clientid = h.clientid
AND d.locationid = h.locationid
AND d.hostname = h.hostname
JOIN plugin_sw_vmware_healthmon_types t
ON t.datavalue = d.cim_value
AND t.datatype = h.vender
WHERE d.cim_item LIKE '%critical array%'
ORDER
BY c.name;
我想要做的是将Corp1的所有结果合并为一行,将Corp2合并到第二行,以便它看起来像这样:
ESXi Host Name Client Name Item Type RAID Status Last Updated (days ago)
192.14.13.2 Corp1 disk array 1 Good 0
192.14.13.2 Corp1 disk array 2 Good 0
192.14.13.2 Corp1 disk array 3 Good 0
192.14.13.2 Corp1 disk array 4 Good 0
192.14.13.2 Corp1 drisk array 5 Good 0
192.16.11.5 Corp 2 disk array 1 Good 4
192.16.11.5 Corp 2 disk array 2 Good 4
192.16.11.5 Corp 2 disk array 3 Good 4
192.16.11.5 Corp 2 disk array 4 Good 4
192.16.11.5 Corp 2 drisk array 5 Good 4
如何在我的查询中执行此操作?
答案 0 :(得分:2)
您可以尝试GROUP_CONCAT
,如下所示:
UIImageView* iv = [[UIImageView alloc] initWithImage:nil highlightedImage:im];
iv.userInteractionEnabled = NO;
[cell addSubview: iv];