Reputation: 33
I have a table in mysql-4.1.22 with huge set of data. And I want to check whether the particular column in my table has distinct values or not(No need to retrieve all distinct values). I have googled and try MYSQL inbuilt function distinct and alternative group by solution but both takes too much amount of time to execute.
Is there any other way to find a column has distinct values or not? . Kindly share your ideas.
Upvotes: 2
Views: 1123
Reputation: 22865
SELECT count(*), count(colname), count(distinct colname)
FROM tabname;
count()
will give you total number of rows in the tabname
;NOT NULL
values in you desired colname
;colname
.Upvotes: 3