I would like to count the number of rows from a mysql table and not to include duplicate en开发者_JAVA技巧tries,
Could I use distinct
with count()
?
Sure.
SELECT COUNT(DISTINCT column) FROM table;
What you need is the following:
SELECT field_type_name, count(*) FROM fields GROUP BY field_type_name;
This will give you something like this:
image 14
string 75
text 9
SELECT COUNT(DISTINCT field) from Table
See this.
SELECT count(DISTINCT column Name) as alias from table_Name;
精彩评论