mysql - Counting how many times each unique element appeared in `select` query -


i have mysql database million of records, table indexed. below table structure.

enter image description here

i ran below code in table.

select `iwebs` `wordstable` `iwebs` 'a1' or `iwebs` 'a2' or `iwebs` 'a3' or `iwebs` 'a4' or `iwebs` 'a5' or `iwebs` 'a6' or `iwebs` 'a7' or `iwebs` 'a8' or `iwebs` 'a9' or `iwebs` 'a10'  

now code generates below output (small part of output displayed).

enter image description here

however, not need. need key-value pair displays how many times each individual element appeared in result. like

[a1,400] [a2,100] [a3,5] [a5,500] ........ 

in above example, first item in each bracket means individual element appeared in select query , second item means number of times appeared.

in other words, means "a1 appeared 400 times in select query", "a2 appeared 100 times in select query", "a3 appeared 5 times in select query" , "a5 appeared 500 times in select query" , on.

how can in sql?

well bit of thinking should able combine solution @ilesh request:

select iwebs, count(iwebs) wordstable iwebs in ('a1','a2','a3','a4') group iwebs 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -