php - Check how many different values there are and return them -


is there way check how many rows different value ( in case ) "subject" are.

for example: in database have 5 rows.

subject of row 1 = 1
subject of row 2 = 5
subject of row 3 = 3
subject of row 4 = 1
subject of row 5 = 8

i want have return like: 1,5,3,8 can notice 1 not showed twice.

does maybe know way done?

thanks!

if want return deduplicated values:

select distinct subject yourtable; 

if want know how many times subject appears in table:

select subject, count(subject) yourtable; 

if want count unique subject values:

select count(distinct subject) yourtable; 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -