SQL Query to avoid duplicate records

SQL Query to avoid duplicate records

In this article, we will find out about copy records and the procedure to stay away from them in our ResultSet while choosing the information.

It’s probably the best practice to consistently utilize unmistakable when we would prefer not to have copy records. The Approach of not having copy records is well known to such an extent that we have a catchphrase called particular which will wrap up of occupation.

At any rate, we can do it physically however will require a great deal of exertion, ordinarily when we don’t have a thought regarding the field which can have copy values. Effect of having these catchphrases is to such an extent that we can make complex question basic.

On the off chance that you are attempting to comprehend what I mean by the copy records, at that point envision a situation where you have a solitary table of item and the table has a field which stores the class name. Presently there can be various items with a similar classification name.

Presently, this isn’t a situation when we have our information in a dreary way. Along these lines, to get the class from this sort of table we should simply to utilize the unmistakable keyword.

Table (representative) having three fields and four information in it,

    Id		Name		Address

    100		Aman		Mumbai
    200		Arun		Pune
    300		Karan		Delhi
    400		Aman		Mumbai
    500		Sumit		Indore

In above table the information of line one and four is same for segment name and address and we have to maintain a strategic distance from the copy line of information in ResultSet so we should simply to utilize DISTINCT watchword before the name of section we are going to bring and it will give us the remarkable columns of information.

Query 1:

SELECT distinct name FROM employee;

Output

SQL Query to avoid duplicate records

Query 2:

SELECT distinct address FROM employee;

Output

SQL Query to avoid duplicate records

DURGESH

I Love python, so I like machine learning a Lot and on the other hand, I like building apps and fun games I post blogs on my website for Tech enthusiast to learn and Share Information With The World.

Leave a Reply

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

5 × one =

Recent Content