Can someone help me, how to count duplicate rows in using mysql . auto count after search or filter but in my code it count all existing data within the range

my code:

            With cmd
                .Connection = con
                .CommandText = "select s_monthname, count(*) as Total from sample2"
                reader = .ExecuteReader
            End With

            da.SelectCommand = cmd
            DataGridView1.DataSource = table1
        Catch ex As MySqlException

        End Try

Please help me

To count record nos. the syntax is

select count(*) from <TableName> Where <Condition>

To get the number of records the syntax is

Dim x as Integer = .ExecuteScalar()
Int x =.ExecuteScalar()

A little addition to Shark_1's post,

You probably will also want to add a Group By onto that select statement. So for instance if you want to see how many occurances there are of the s_monthname in the table, but only return distinct records in relation to the month name (so only 1 record) you could do something like

select s_monthname, count(*) as Total from sample2 GROUP BY s_monthname

Not only will that return the s_monthname value, but the Total will be how many times that a value in that column has occured in the table (but all in one record)

yeah yeah.. all in one record will display.. so this is the right syntax? gonna try this one
This question has already been answered. Start a new discussion instead.