How to show only non duplicate records in mysql

Consider the below is the table name “student”

Now there are plenty of duplicate records in the above table right?.
Showing the duplicate records is easy in MySQL if you use GROUP BY in the SQL Query you will get it easily.

But have you ever tried to get only non-duplicate records from a table?.
In the above table if you see the records in the column ‘name’. a,b is repeated two times. c,d,e are not repeated right?.

So, how can you show only c,d,e from the above table?. Don’t worry i will explain how can you do it!
Below Query will help you to get what you are looking for..

SELECT s_id, name FROM table GROUP BY name HAVING COUNT(*) = 1;

I hope now you get a clear idea of what to do right?. Okay then try and let me know if you have any doubt.

[ad] [ad]

Add a Comment

Your email address will not be published. Required fields are marked *