$query1 = "SELECT
SUM(dischargecount) AS dis, MONTHNAME(dischargedate) AS n
FROM
user
WHERE
DATE(dischargedate) BETWEEN '$from' AND '$to'
GROUP BY MONTH(dischargedate)";
$query2 = "SELECT
COUNT(DISTINCT response_user) AS val1,
MONTHNAME(response_on) AS m
FROM
response
WHERE
response_on BETWEEN '$from' AND '$to'
GROUP BY MONTH(response_on)";
我想将两个查询作为一个执行。
答案 0 :(得分:0)
从$ query1 $ q1,$ query2 $ q2中选择col_name $ q1,col_name $ q2,其中condition1和condition2;
答案 1 :(得分:0)
SELECT
SUM(dischargecount) AS dis, MONTHNAME(dischargedate) AS n
FROM
user
WHERE
DATE(dischargedate) BETWEEN '$from' AND '$to'
GROUP BY MONTH(dischargedate)
UNION ALL
SELECT
COUNT(DISTINCT response_user) AS val1,
MONTHNAME(response_on) AS m
FROM
response
WHERE
response_on BETWEEN '$from' AND '$to'
GROUP BY MONTH(response_on)