How to use 2 MySQL SELECT Statements in one PHP query -


please me figure out how put following 2 statements 1 query. appreciated.

    $sql1 = 'select count(id) total_cat_votes votes category_id="1"';     $sql2 = 'select count(nominee_id') total_nom_votes votes category_id="1" , nominee_id="16"'; 

my idea here have table called votes , want number of total votes specific category under category_id different total votes of each nominee under nominee_id. hope clear enough.

thanks help!

use sum() second count condition ,using sum condition result in boolean 0 or 1,also using aggregate functions without grouping them result in single row

select count(id) total_cat_votes, sum(nominee_id='16') total_nom_votes votes  category_id='1' 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -