Is there any way to combine the following queries (Can we combine these queries by using COUNT or another way).
$resultacgc = mysql_query("SELECT mno FROM table1 WHERE (m_jid='$sid' AND decision='accept-gf')");
$numacgc = mysql_num_rows($resultacgc);
$resultacp = mysql_query("SELECT mno FROM table1 WHERE (m_jid='$sid' AND decision='accept-p')");
$numacp = mysql_num_rows($resultacp);
$resultacpc = mysql_query("SELECT mno FROM table1 WHERE (m_jid='$sid' AND decision='accept-pc')");
$numacpc = mysql_num_rows($resultacpc);
$resultacr = mysql_query("SELECT mno FROM table1 WHERE (m_jid='$sid' AND decision='accept-rdy')");
$numacr = mysql_num_rows($resultacr);
$resultacft = mysql_query("SELECT mno FROM table1 WHERE (m_jid='$sid' AND decision='accept-ft')");
$numacft = mysql_num_rows($resultacft);
P.S.:I know "mysql_*" is deprecated.
thank you
You can use mysql IN.
Like so:
"SELECT mno FROM table1 WHERE (m_jid='$sid' AND decision IN ('accept-gf', '...', '...'))"
In case you want to get each count you would need to do something like this:
"SELECT decision, COUNT(*) AS count FROM table1 WHERE (m_jid='$sid' AND decision IN ('accept-gf', '...', '...')) GROUP BY decision"