Nick
Nick

Reputation: 1

Select query showing less row and distinct, count showing more rows

I am getting the wrong result from Distinct query.

I have trying to get result from column where distinct values but while I am running query

select distict(column_name) from tbl_name;

Getting output : 241091

While I am running :

select * from tbl_name;

getting output : 240469

the output changed.

If I run

select count(*) from tbl_name;

getting output : 241091

Please do help why output varies.

expected result total no of rows distinct showing more value

Upvotes: 0

Views: 640

Answers (1)

ack_inc
ack_inc

Reputation: 1113

This query: select count(*) from tbl_name; gives you the exact count of the rows in the table.

The number you're seeing when you run this one: select * from tbl_name; is an approximation.

The accepted answer to this question has more details: Why is the estimated rows count very different in phpmyadmin results?

Upvotes: 0

Related Questions