In order to explain how DISTINCT works let us see an example

Let’s say we have table of  books storing Book Title and Author details. It is possible that one author can write several books.

book_title——– author

Book A————–Author A

Book B————–Author B

Book C————–Author A

Book D————–Author C

Now we want to write a query which will return all authors

If we run following query

SELECT author from books

We will get

Author A, Author B, Author A, Author C

Note that Author A appears twice

To correct this problem we run below query


This will return

Author A, Author B, Author C

Leave a Reply

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