0
Indivudually這些查詢運行100%如何加入PHP 2個MySQL查詢作爲hetml返回值
QUERY1
SELECT year_entered,
month_entered,
IFNULL(amount - @n, 0) amount_diff,
@n := amount current_amount
FROM
(SELECT YEAR(date_entered) year_entered,
MONTHNAME(date_entered) month_entered,
SUM(amount) amount
FROM opportunities
INNER JOIN opportunities_cstm
ON (opportunities.id = opportunities_cstm.id_c)
WHERE
YEAR(opportunities.date_entered) >= YEAR(CURDATE())
AND (`opportunities`.`deleted` <> '1') AND
(opportunities_cstm.interest_level_c = 'Ultraspin'
OR
opportunities_cstm.interest_level_c = 'Mycelx')
GROUP BY YEAR(date_entered), MONTH(date_entered)) q,
(SELECT @n := NULL) n
查詢2
SELECT year_entered,
month_entered,
IFNULL(id - @n, 0) id_diff,
@n := id current_id
FROM
(SELECT YEAR(date_entered) year_entered,
MONTHNAME(date_entered) month_entered,
COUNT(id) id
FROM opportunities
INNER JOIN opportunities_cstm
ON (opportunities.id = opportunities_cstm.id_c)
WHERE
YEAR(opportunities.date_entered) >= YEAR(CURDATE())
AND (`opportunities`.`deleted` <> '1') AND
(opportunities_cstm.interest_level_c = 'Ultraspin'
OR
opportunities_cstm.interest_level_c = 'Mycelx')
GROUP BY YEAR(date_entered), MONTH(date_entered)) q,
(SELECT @n := NULL) n
ON year_entered = year_entered
我需要怎麼量的差異和在一個查詢計數差異,想要用戶賈斯珀報告來報告這一點,或者如果有人可以幫助PHP返回行?
只是不知道如何在查詢和返回旁邊它們彼此