How can I combine this two query into one thank you in advance.
$mayorcountqry = $conn->prepare("SELECT VOTE_STATUS FROM voters where VOTE_STATUS = ? AND prcnt_no = ? ");
$mayorcountqry->execute([$MAYOR,$prcnt_no]);
$countmayor = $mayorcountqry->rowCount();
$triocountqry = $conn->prepare("SELECT VOTE_STATUS FROM voters where VOTE_STATUS = ? AND prcnt_no = ? ");
$triocountqry->execute([$TRIO,$prcnt_no]);
$triocount= $triocountqry->rowCount();
Have you tried SQL Union?
Syntax:
SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
You can then just count for each.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.