mysql - Display only one row for values that appear multiple times -


i have multiple rows same name in table, , want show 1 of row of each. example, following data:

| name | number | +------+--------+ | exe  |   1    | | exe  |   10   | | exe  |   2    | | bat  |   1    | | exe  |   3    | | bat  |   4    | 

i see following results:

| name | number |  +------+--------+ | exe  |  16    | | bat  |  5     | 

how can achieve result?

duplicate response: question have 1 table, join ..on command creates confusion in understanding, think simple question can many guys!

try this:

  select t.`name`, sum(t.`number`) `number`     mytable t    group t.`name`    order `number` desc 

let database return result want, rather mucking returning bloatload of rows, , collapsing them on client side. there's plenty of work client without doing database can way more efficiently.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -