php - Is there a way to combine various MYSQL queries with multiple WHERE clauses? -


i have following queries

$queryrs12c = "select count(*) total, sum(goals) sumgoals, sum(assists) sumassists, sum(minutes) summinutes `player` season='12' , gametype='club' ";  $queryrs11c = "select count(*) total, sum(goals) sumgoals, sum(assists) sumassists, sum(minutes) summinutes `player` season='11' , gametype='club' ";  $queryrs10c = "select count(*) total, sum(goals) sumgoals, sum(assists) sumassists, sum(minutes) summinutes `player` season='10' , gametype='club' "; 

etc

i have query 12 times cycling through 1-12

i take results of each query through loop generate 12 tables of data.

is there way combine 12 of queries still retain ability generate 12 tables of data?

(12 queries doesn't seem lot have other sets of similar queries, 1 10 queries, 1 12 , 1 13 , there many variables have cycle through.)

you should using group clause, allow use aggregate functions sum() each variation in column grouping. in case, might this:

select     season,     count(*) total,     sum(goals) sumgoals,     sum(assists) sumassists,     sum(minutes) summinutes `player` gametype='club' group season order season desc /* or asc whichever wish */ 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -