我正在尝试将同一表中的三个选择语句组合在一起,以便使用结果完成a。代码当前使用返回:
资源ID#3资源ID#4资源ID#5
我已经对工会或加入进行了一些研究,但是我还没有发现任何有用的东西。这是我当前的方法:
$statecount = pg_query($conn, "
SELECT
COUNT (*) as totalst
FROM
fpscdb001_ws_001.incident
WHERE
incident.initial_symptom = 'Chrome Install' AND
incident.state_1 = 'MA';");
$sched = pg_query($conn, "
SELECT
COUNT (*) as totalsch
FROM
fpscdb001_ws_001.incident
WHERE
incident.initial_symptom = 'Chrome Install' AND
incident.state_1 = 'MA' AND
incident.status_1 = 'Scheduled';");
$closed = pg_query($conn, "
SELECT
COUNT (*) as totaldone
FROM
fpscdb001_ws_001.incident
WHERE
incident.initial_symptom = 'Chrome Install' AND
incident.state_1 = 'MA' AND
incident.status_1 = 'Closed';");
if (!$statecount) {
echo "Query failed on state count.n";
exit;
}
if (!$sched) {
echo "Query failed on sched.n";
exit;
}
if (!$closed) {
echo "Query failed on closed.n";
exit;
}
{
echo "<td> $statecount </td>";
echo "<td> $sched </td>";
echo "<td> $closed </td>";
}
pg_close($conn);
通过一些反复试验,我能够使它起作用...
$statecount = pg_query($conn, "
SELECT
COUNT (*) as totalst
FROM
fpscdb001_ws_001.incident
WHERE
incident.initial_symptom = 'Chrome Upgrade' AND
incident.state_1 = 'AR' AND
incident.status_1 != 'Closed'
UNION ALL
SELECT
COUNT (*) as totalsch
FROM
fpscdb001_ws_001.incident
WHERE
incident.initial_symptom = 'Chrome Upgrade' AND
incident.state_1 = 'AR' AND
incident.staging = 'True' AND
incident.is_installed != 'True' AND
incident.status_1 != 'Closed'
UNION ALL
SELECT
COUNT (*) as totaldone
FROM
fpscdb001_ws_001.incident
WHERE
incident.initial_symptom = 'Chrome Upgrade' AND
incident.state_1 = 'AR' AND
incident.staging = 'True' AND
incident.is_installed = 'True';");
if (!$statecount) {
echo "Query failed on state count.n";
exit;
}
while ($counts = pg_fetch_row($statecount)){
echo "<td>$counts[0]</td>";
}