mysql - value of SELECT COUNT(DISTINCT allcolumns) bigger than SELECT COUNT(1) -
i run following sql in mysql, , why 2 count
show different results?
select count(1), count(distinct column1, column2, column3, column4, column5) distinctcount `parts_color`;
the results are:
count(1)
: 647611distinctcount
: 647263
why?
your table parts_color must have duplicate values.
select count(1) similar select count(*) retains duplicate values , returns count.
when use distinct in query duplicate values discarded , hence value less count(1).
Comments
Post a Comment